codeforces_813A. The Contest
2017-06-06 09:44
281 查看
http://codeforces.com/problemset/problem/813/A
注意区分总的时间在哪个区间。
注意区分总的时间在哪个区间。
#include <iostream> using namespace std; int main() { int first; cin>>first; int a[first]; long long sum=0; for(int i=0; i<first; i++) { cin>>a[i]; sum=sum+a[i]; } int third; cin>>third; if(third==0) { cout<<"-1"<<endl; return 0; } int b[third][2]; for(int i=0; i<third; i++) { for(int j=0; j<2; j++) { cin>>b[i][j]; } if(sum<b[i][0]) { cout<<b[i][0]<<endl;return 0; } if(sum>=b[i][0]&&sum<=b[i][1]) { cout<<sum<<endl;return 0; } } if(sum>b[third-1][1]) { cout<<"-1"<<endl; } return 0; }
相关文章推荐
- 【codeforces】2014-2015 ACM-ICPC, Central Europe Regional Contest (CERC 14) F Vocabulary【dp】
- Codeforces 2016-2017 ACM-ICPC, NEERC, Southern Subregional Contest (Online Mirror)
- Codeforces-20152016-northwestern-european-regional-contest-nwerc-A题
- CodeForces-999A-Mishka and Contest
- codeforces contest 855 problem C(树形DP)
- 【Codeforces】2015-2016 ACM-ICPC Nordic Collegiate Programming Contest (NCPC 2015) A Adjoin the Netwo
- Codeforces April Fools Contest 2017
- Codeforces 2016 ACM Amman Collegiate Programming Contest A. Coins(动态规划/01背包变形)
- codeforces contest 339
- codeforces contest 869 problem C(组合数)
- codeforces contest 13 problem E(分块)
- Codeforces contest 295 recordings
- CodeForces 377B---Preparing for the Contest(二分+贪心)
- codeforces contest 344
- Codeforces 2015-2016 ACM-ICPC, NEERC, Southern Subregional Contest I题(模拟)
- Codeforces 2015-2016 ACM-ICPC, NEERC, Southern Subregional Contest J题(BFS)
- CodeForces 377B---Preparing for the Contest(二分+贪心)
- codeforces 442 A. Alex and broken contest(水题)
- Codeforces 656 B. Scrambled(April Fools Day Contest 2016)
- Codeforces 501A:Contest(水题)