Submission #478020

# Submission time Handle Problem Language Result Execution time Memory
478020 2021-10-05T06:06:11 Z LouayFarah Remittance (JOI19_remittance) C++14
0 / 100
1 ms 320 KB
#include "bits/stdc++.h"

using namespace std;

#define endl "\n"
#define ll long long
#define pb push_back
#define mp make_pair

const long long MOD = 1e9+7;
const long long INF = 1e18;


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


    ll n;
    cin >> n;

    vector<ll> a(n, 0), b(n, 0);

    for(int i = 0; i<n; i++)
        cin >> a[i] >> b[i];

    for(int i = 0; i<n-1; i++)
    {
        if(a[i]>b[i])
        {
            ll A = a[i], B = b[i];
            ll orig = a[i+1];
            a[i+1]+=ceil(double(A-B)/2);
            orig = a[i+1]-orig;
            a[i]-=2*orig;
        }
    }
    if(a[n-1]>b[n-1])
    {
        ll A = a[n-1], B = b[n-1];
        ll orig = a[0];
        a[0]+=ceil(double(A-B)/2);
        orig = a[0]-orig;
        a[n-1]-=2*orig;
    }

    for(int i = 0; i<n-1; i++)
    {
        if(a[i]>b[i])
        {
            ll A = a[i], B = b[i];
            ll orig = a[i+1];
            a[i+1]+=ceil(double(A-B)/2);
            orig = a[i+1]-orig;
            a[i]-=2*orig;
        }
    }
    if(a[n-1]>b[n-1])
    {
        ll A = a[n-1], B = b[n-1];
        ll orig = a[0];
        a[0]+=ceil(double(A-B)/2);
        orig = a[0]-orig;
        a[n-1]-=2*orig;
    }

    bool flag = true;
    for(int i = 0; i<n; i++)
    {
        if(a[i]!=b[i])
        {
            flag = false;
            break;
        }
    }

    if(flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 1 ms 312 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 1 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 0 ms 208 KB Output is correct
12 Correct 1 ms 316 KB Output is correct
13 Correct 1 ms 208 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 1 ms 316 KB Output is correct
16 Correct 1 ms 208 KB Output is correct
17 Correct 1 ms 312 KB Output is correct
18 Correct 1 ms 208 KB Output is correct
19 Correct 1 ms 208 KB Output is correct
20 Incorrect 0 ms 208 KB Output isn't correct
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 1 ms 312 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 1 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 0 ms 208 KB Output is correct
12 Correct 1 ms 316 KB Output is correct
13 Correct 1 ms 208 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 1 ms 316 KB Output is correct
16 Correct 1 ms 208 KB Output is correct
17 Correct 1 ms 312 KB Output is correct
18 Correct 1 ms 208 KB Output is correct
19 Correct 1 ms 208 KB Output is correct
20 Incorrect 0 ms 208 KB Output isn't correct
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 1 ms 312 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 1 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 0 ms 208 KB Output is correct
12 Correct 1 ms 316 KB Output is correct
13 Correct 1 ms 208 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 1 ms 316 KB Output is correct
16 Correct 1 ms 208 KB Output is correct
17 Correct 1 ms 312 KB Output is correct
18 Correct 1 ms 208 KB Output is correct
19 Correct 1 ms 208 KB Output is correct
20 Incorrect 0 ms 208 KB Output isn't correct
21 Halted 0 ms 0 KB -