Submission #292150

# Submission time Handle Problem Language Result Execution time Memory
292150 2020-09-06T12:52:27 Z muhammad_hokimiyon Remittance (JOI19_remittance) C++14
0 / 100
1 ms 384 KB
#include <bits/stdc++.h>

#define fi first
#define se second
#define ll long long
#define dl double long

using namespace std;

const int N = 1e6 + 7;
const int M = 20 + 7;
const ll mod = 1e9 + 7;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n;
ll a[N];
ll b[N];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    //freopen( "input.txt" , "r" , stdin );
    //freopen( "output.txt" , "w" , stdout );

    cin >> n;
    for( int i = 0; i < n; i++ ){
        cin >> a[i] >> b[i];
    }
    assert( n > 1 );
    for( int it = 0; it < 35; it++ ){
        for( int i = 0; i < n; i++ ){
            if( a[i] > b[i] ){
                int nx = (i + 1) % n;
                ll cost = (a[i] - b[i]) / 2;
                assert( cost >= 0 );
                a[nx] += cost;
                a[i] -= cost * 2;
            }
            assert( a[i] >= 0 && b[i] >= 0 );
        }
    }
    bool f = true;
    for( int i = 0; i < n; i++ )f &= (a[i] == b[i]);
    cout << (f ? "Yes" : "No");
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Incorrect 1 ms 384 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Incorrect 1 ms 384 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Incorrect 1 ms 384 KB Output isn't correct
9 Halted 0 ms 0 KB -