Submission #1010674

# Submission time Handle Problem Language Result Execution time Memory
1010674 2024-06-29T09:28:29 Z Ice_man Remittance (JOI19_remittance) C++14
0 / 100
1 ms 348 KB
/**
 ____    ____    ____    __________________    ____    ____    ____
||I ||  ||c ||  ||e ||  ||                ||  ||M ||  ||a ||  ||n ||
||__||  ||__||  ||__||  ||________________||  ||__||  ||__||  ||__||
|/__\|  |/__\|  |/__\|  |/________________\|  |/__\|  |/__\|  |/__\|

*/

#include <iostream>
#include <chrono>
#include <vector>

#define maxn 100005
#define maxlog 20
#define INF 1000000010
#define LINF 1000000000000000005
#define endl '\n'
#define pb(x) push_back(x)
#define X first
#define Y second
#define control cout<<"passed"<<endl;

#pragma GCC optimize("O3" , "Ofast" , "unroll-loops" , "fast-math")
#pragma GCC target("avx2")

using namespace std;


typedef pair <int, int> pii;
typedef long long ll;
typedef pair <ll, ll> pll;
typedef pair <int, ll> pil;
typedef pair <ll, int> pli;
typedef long double ld;


std::chrono::high_resolution_clock::time_point startT, currT;
constexpr double TIME_MULT = 1;

double timePassed()
{
    using namespace std::chrono;
    currT = high_resolution_clock::now();
    double time = duration_cast<duration<double>>(currT - startT).count();
    return time * TIME_MULT;
}



int v[maxn];
ll n, a[maxn], b[maxn];

void read()
{
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> a[i] >> b[i];

    for(int i = 1; i <= n - 1; i++)
        v[i] = i + 1;
    v[n] = 1;
}


void make_step()
{
    for(int i = 1; i <= n; i++)
    {
        if(a[i] <= b[i] + 1)
            continue;

        ll money;
        if(a[i] - b[i] % 2 == 1)
            money = (a[i] - b[i] + 1) / 2;
        else
            money = (a[i] - b[i]) / 2;

        a[i] -= money * 2;
        a[v[i]] += money;
    }

    for(int i = 1; i <= 1; i++)
    {
        if(a[i] <= b[i] + 1)
            continue;

        ll money;
        if(a[i] - b[i] % 2 == 1)
            money = (a[i] - b[i] + 1LL) / 2;
        else
            money = (a[i] - b[i]) / 2;

        a[i] -= money * 2;
        a[v[i]] += money;
    }
}



void solve()
{
    int constant = 100000;
    while(constant--)
    {
        make_step();

        bool lamp = true;
        for(int i = 1; i <= n; i++)
            if(a[i] != b[i])
                lamp = false;

        if(lamp == true)
        {
            cout << "Yes" << endl;
            return;
        }

    }

    cout << "No" << endl;
}






int main()
{

    /**#ifdef ONLINE_JUDGE
        freopen("input.in", "r", stdin);
        freopen("output.out", "w", stdout);
    #endif*/

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    ///startT = std::chrono::high_resolution_clock::now();

    read();
    solve();


    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Incorrect 1 ms 348 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Incorrect 1 ms 348 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Incorrect 1 ms 348 KB Output isn't correct
9 Halted 0 ms 0 KB -