codeforces_813A. The Contest

来源:互联网 发布:s7200仿真软件下载 编辑:程序博客网 时间:2024/06/06 18:37

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;}
原创粉丝点击