【CodeForces】[366A]Dima and Guards

文章字数:159

问题描述

问题分析

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

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
#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

该内容采用 CC BY-NC-SA 4.0 许可协议。

如果对您有帮助或存在意见建议,欢迎在下方评论交流。

加载中...