您的位置:首页 > 其它

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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: