Submission #1010702

# Submission time Handle Problem Language Result Execution time Memory
1010702 2024-06-29T09:43:37 Z Ice_man Remittance (JOI19_remittance) C++14
0 / 100
3 ms 600 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];
int bra0 = 0, brb0 = 0;

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

    for(int i = 1; i <= n; i++)
    {
        if(a[i] == 0)
            bra0++;
        if(b[i] == 0)
            brb0++;
    }

    if(brb0 == n && bra0 != n)
    {
        cout << "No" << endl;
        return;
    }

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


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

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

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

    for(int i = 1; i <= 1; i++)
    {
        if(a[i] <= b[i])
            continue;
        ll money = (a[i] - b[i] + 1) / 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;

        /**cout << "-------------" << endl;
        for(int i = 1; i <= n; i++)
            cout << a[i] << " ";
        cout << endl << "---------------------" << endl;*/


        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 3 ms 344 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 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 2 ms 464 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 0 ms 600 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Incorrect 1 ms 344 KB Output isn't correct
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 344 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 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 2 ms 464 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 0 ms 600 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Incorrect 1 ms 344 KB Output isn't correct
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 344 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 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 2 ms 464 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 0 ms 600 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Incorrect 1 ms 344 KB Output isn't correct
21 Halted 0 ms 0 KB -