Submission #140466

# Submission time Handle Problem Language Result Execution time Memory
140466 2019-08-03T08:01:17 Z blue Remittance (JOI19_remittance) C++11
0 / 100
3 ms 380 KB
#include <iostream>
using namespace std;

int main()
{
    int n;
    cin >> n;
    
    int A[n], B[n];
    int s, sv = -2000000000;
    for(int 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(int t = 1; t <= 3; 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(int 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);
        }
    }
    for(int 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 3 ms 376 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 380 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Incorrect 2 ms 376 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 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 380 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Incorrect 2 ms 376 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 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 380 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Incorrect 2 ms 376 KB Output isn't correct
9 Halted 0 ms 0 KB -