Codeforces 813 A The Contest
来源:互联网 发布:hp1536 无线连接网络 编辑:程序博客网 时间:2024/06/06 07:16
题目地址:http://codeforces.com/contest/813/problem/A
题意:题目就是说有n道题,分别告诉你每道题你解决需要的时间,然后告诉你在m个时间段内可以提交,让你告诉他,他什么时候可以提交完所有的题目,提交不算时间。
思路:其实你会发现因为提交不要时间所有你先把解决所有题目的总时间算出来,再找这个大于或者包括这个总时间的最早的时间段就好了。
#include <iostream>#include <cstring>#include <string>#include <queue>#include <map>#include <algorithm>#define N 1000#define inf 0x3f3f3f3fusing namespace std;int main() { cin.sync_with_stdio(false); int n, m; int sum, num, a, b; while (cin >> n) { sum = 0; for (int i = 0; i < n; i++) { cin >> num; sum += num; } cin >> m; int flag = 1; for (int i = 0; i < m; i++) { cin >> a >> b; if (b >= sum&&flag) { flag = 0; cout << max(sum, a) << endl; } } if (flag) { cout << -1 << endl; } } return 0;}
阅读全文
0 0
- CodeForces 813A The Contest
- Codeforces 813 A The Contest
- Codeforces 813A The Contest 题解
- Educational Codeforces Round 22 A. The Contest
- codeforces April Fools Day Contest 2014 A. The Great Game
- CodeForces 501A Contest
- CodeForces 501A Contest
- codeforces 501A Contest
- codeforces contest 785 a题
- codeforces contest 779 A题
- codeforces/contest/797/problem/A
- cf#3A Shortest path of the kinghttp://codeforces.com/contest/3/problem/A
- CodeForces - 681A A Good Contest
- CodeForces 681A A Good Contest
- codeforces 681A A Good Contest
- 【Codeforces】2015-2016 ACM-ICPC Nordic Collegiate Programming Contest (NCPC 2015) A Adjoin the Netwo
- CodeForces 377 B. Preparing for the Contest
- codeforces 377B Preparing for the Contest
- [AHK]遍历窗口
- 深入理解js闭包
- 初学数据结构---树和二叉树
- WeX5之Data插入
- 常用命令
- Codeforces 813 A The Contest
- Spark、hadoop源码编译
- ajax在PC上运行正常,打包到手机后就报error0错误
- QPixmap load jpg图片失败的解决方法
- WeX5调用jQuery格式问题
- 强分类器(提升方法)-----------AdaBoost算法原理和推导过程
- [AHK]AutoHotkey也玩神经网络实现OR逻辑感知器
- 蓝桥杯 PREV-1 历届试题 核桃的数量
- 爬取南京邮电大学党委宣传部