Submission #773665

# Submission time Handle Problem Language Result Execution time Memory
773665 2023-07-05T07:41:42 Z CyberCow Remittance (JOI19_remittance) C++17
15 / 100
179 ms 340 KB
//#include <bits/stdc++.h>
#include <random>
#include <algorithm>
#include <bitset>
#include <chrono>
#include <cmath>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <chrono>
#define fr first
#define sc second
#define ad push_back
using namespace std;
using ll = long long;
mt19937 rnd(348502);
const int N = 1000005;
int a[N], b[N];

void solve()
{
    int n, i, j, x, y, gum1 = 0, gum = 0;
    cin >> n;
    for ( i = 1; i <= n; i++)
    {
        cin >> a[i] >> b[i];
        gum += a[i];
        gum1 += b[i];
    }
    i = 0;
    int st = 0, qan = 0;
    while (gum >= gum1)
    {
        qan++;
        i++;
        if (i == n + 1)
        {
            if (st == n)
                break;
            i = 1;
            st = 0;
        }
        if (i < n)
        {
            if (a[i] > b[i])
            {
                if (a[i] - (a[i] - b[i] + 1) / 2 * 2 >= 0)
                {
                    gum -= (a[i] - b[i] + 1) / 2 * 2;
                    gum += (a[i] - b[i] + 1) / 2;
                    a[i + 1] += (a[i] - b[i] + 1) / 2;
                    a[i] -= (a[i] - b[i] + 1) / 2 * 2;
                }
            }
        }
        else
        {
            if (a[i] > b[i])
            {
                if (a[i] - (a[i] - b[i] + 1) / 2 * 2 >= 0)
                {
                    gum -= (a[i] - b[i] + 1) / 2 * 2;
                    gum += (a[i] - b[i] + 1) / 2;
                    a[1] += (a[i] - b[i] + 1) / 2;
                    a[i] -= (a[i] - b[i] + 1) / 2 * 2;
                }
            }
        }
        if (a[i] == b[i])
            st++;
        if (qan >= 100000000)
            break;
    }
    if (gum == gum1 && qan != 100000000)
        cout << "Yes";
    else
        cout << "No";
}


int main() {    
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll tt = 1;
    //cin >> tt;
    while (tt--) {
        solve();
    }
    return 0;
}

Compilation message

remittance.cpp: In function 'void solve()':
remittance.cpp:33:15: warning: unused variable 'j' [-Wunused-variable]
   33 |     int n, i, j, x, y, gum1 = 0, gum = 0;
      |               ^
remittance.cpp:33:18: warning: unused variable 'x' [-Wunused-variable]
   33 |     int n, i, j, x, y, gum1 = 0, gum = 0;
      |                  ^
remittance.cpp:33:21: warning: unused variable 'y' [-Wunused-variable]
   33 |     int n, i, j, x, y, gum1 = 0, gum = 0;
      |                     ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 179 ms 212 KB Output is correct
17 Correct 168 ms 324 KB Output is correct
18 Correct 1 ms 308 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 153 ms 336 KB Output is correct
21 Correct 169 ms 336 KB Output is correct
22 Correct 150 ms 340 KB Output is correct
23 Correct 163 ms 320 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 145 ms 320 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 316 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 137 ms 324 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 179 ms 212 KB Output is correct
17 Correct 168 ms 324 KB Output is correct
18 Correct 1 ms 308 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 153 ms 336 KB Output is correct
21 Correct 169 ms 336 KB Output is correct
22 Correct 150 ms 340 KB Output is correct
23 Correct 163 ms 320 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 145 ms 320 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 316 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 137 ms 324 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 336 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Incorrect 1 ms 340 KB Output isn't correct
37 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 179 ms 212 KB Output is correct
17 Correct 168 ms 324 KB Output is correct
18 Correct 1 ms 308 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 153 ms 336 KB Output is correct
21 Correct 169 ms 336 KB Output is correct
22 Correct 150 ms 340 KB Output is correct
23 Correct 163 ms 320 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 145 ms 320 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 316 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 137 ms 324 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 336 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Incorrect 1 ms 340 KB Output isn't correct
37 Halted 0 ms 0 KB -