Submission #140475

# Submission time Handle Problem Language Result Execution time Memory
140475 2019-08-03T08:09:46 Z blue Remittance (JOI19_remittance) C++11
0 / 100
2 ms 376 KB
#include <iostream>
using namespace std;

int main()
{
    long long n;
    cin >> n;
    
    long long A[n], B[n];
    long long s, sv = -4000000000000000000;
    for(long long i = 0; i < n; i++) 
    {
        cin >> A[i] >> B[i];
        
        if(A[i] - B[i] > sv)
        {
            sv = A[i] - B[i];
            s = i;
        }
    }
    if(sv < 0) 
    {
        cout << "No\n";
        return 0;
    }
    for(long long t = 1; t <= 5; t++)
    {
        if(A[s] - B[s] > 1)
        {
            A[(s+1) % n] += (A[s] - B[s]) / 2;
            A[s] -= 2*((A[s] - B[s]) / 2);
        }
        for(long long i = (s+1)%n; i != s; i = (i+1)%n)
        {
            if(A[i] - B[i] <= 0) continue;
            A[(i+1)%n] += (A[i] - B[i]) / 2;
            A[i] -= 2*((A[i] - B[i]) / 2);
        }
        sv = -4000000000000000000;
        for(long long i = 0; i < n; i++) 
        {
            if(A[i] - B[i] > sv)
            {
                sv = A[i] - B[i];
                s = i;
            }
        }    
    }
    for(long long i = 0; i < n; i++)
    {
        if(A[i] == B[i]) continue;
        cout << "No\n";
        return 0;
    }
    cout << "Yes\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 252 KB Output is correct
8 Incorrect 2 ms 256 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 252 KB Output is correct
8 Incorrect 2 ms 256 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 252 KB Output is correct
8 Incorrect 2 ms 256 KB Output isn't correct
9 Halted 0 ms 0 KB -