제출 #147181

#제출 시각아이디문제언어결과실행 시간메모리
147181Alexa2001Remittance (JOI19_remittance)C++17
0 / 100
2 ms424 KiB
#include <bits/stdc++.h>
#define yes { cout << "Yes\n"; exit(0); }
#define no { cout << "No\n"; exit(0); }

using namespace std;

const int Nmax = 1e6 + 5;
typedef long long ll;

int n, a[Nmax], b[Nmax];

int main()
{
 //   freopen("rem.in", "r", stdin);
    cin.tie(0); cin.sync_with_stdio(false);

    int i, j;
    ll s1 = 0, s2 = 0;

    cin >> n;
    for(i=1; i<=n; ++i) cin >> a[i] >> b[i], s1 += a[i], s2 += b[i];

    for(i = s1 - s2; i >= 0; --i)
    {
        for(j=1; j<=n; ++j)
            if(a[j] > b[j]) break;

        if(i == 0)
        {
            if(j == n+1) yes
                else no
        }

        a[j] -= 2; 
        if(j < n) a[j+1] ++;
            else a[1] ++;
    }    

    no

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...