【CodeForces】[366A]Dima and Guards

这里写图片描述

初看题以为是非常麻烦的题
但Special Judge的好处
就是只要满足题意得输出都可以

所以只需要在四个中找出一组满足的输出就好
找不到就输出-1

#include<stdio.h>
int main() {
    int n;
    while(scanf("%d",&n)!=EOF) {
        int rest=-1,res;
        for(int i=1; i<5; i++) {
            int a,b,c,d;
            scanf("%d %d %d %d",&a,&b,&c,&d);
            if((a<b?a:b)+(c<d?c:d)<=n)
                rest=i,res=(a<b?a:b);
        }
        if(rest==-1)
            printf("-1\n");
        else
            printf("%d %d %d\n",rest,res,n-res);
    }
    return 0;
}

题目地址:【CodeForces】[366A]Dima and Guards

posted @ 2016-06-01 01:45  BoilTask  阅读(14)  评论(0编辑  收藏  举报