답안 #657217

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
657217 2022-11-09T08:39:56 Z snowman 송금 (JOI19_remittance) C++17
100 / 100
316 ms 20804 KB
#include <bits/stdc++.h>
//Soltan Cristian
#define fri(a, b) for (int i = (a); i < (b); ++i)
#define frj(a, b) for(int j = a; j < b; j++)
#define frk(a, b) for(int k = a; k < b; k++)
#define frm(a, b, i) for(int i = b; i >= a; i--)
#define ll long long
#define all(x) x.begin(), x.end()
#define mod 1000000007
#define pb push_back
#define st first
#define nd second
#define sz(x) (int)x.size()
#define rall(x) x.rbegin(), x.rend()
#define ct(x) cout << x
#define cts(x) cout << x << ' '
#define ctn(x) cout << x << '\n'
#define Y cout << "YES" << '\n'
#define N cout << "NO" << '\n'
using namespace std;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vb = vector<bool>;
using ml = map<ll, ll>;
using vii = vector<vector<int>>;
using vll = vector<vector<ll>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template <typename T>void read(T n, vector<T> &a){fri(0, n){cin >> a[i];}}
template<typename T>void print(T n, T m, vector<vector<T>> &dp){fri(0, n){ct('\n');frj(0, m){ct(setw(5));cts(dp[i][j]);}}}


const int mxa = 100019;
// string __fname = "invector"; ifstream in(__fname + ".in"); ofstream out(__fname + ".out");
// #define cin in 
// #define cout out



void solve(){
    int n;
    cin >> n;
    vi a(n), b(n);
    fri(0, n){
        cin >> a[i] >> b[i];
    }
    frj(0, 30){
        fri(0, n){
            if(a[i] > b[i]){
                if(i < n - 1){
                    if(a[i] - b[i] > 0 && (a[i] - b[i]) % 2 == 0){
                        a[i + 1] += (a[i] - b[i]) / 2;
                        a[i] = b[i];
                    }
                    else if(a[i] - b[i] > 0 && b[i] > 0){
                        a[i + 1] += (a[i] - b[i] + 1)/ 2;
                        a[i] = b[i] - 1;
                    }
                }
                if(i == n - 1){
                    if(a[i] - b[i] > 0 &&(a[i] - b[i]) % 2 == 0){
                        a[0] += (a[i] - b[i]) / 2;
                        a[i] = b[i];
                    }
                    else if(a[i] - b[i] > 0 && b[i] > 0){
                        a[0] += (a[i] - b[i] + 1)/ 2;
                        a[i] = b[i] - 1;
                    }
                }
            }
        }
    }
    fri(0, n){
        if(a[i] != b[i]){
            cout << "No" << '\n';
            return;
        }
    }
    cout << "Yes" << '\n';
}


int main()
{   

    ios_base::sync_with_stdio(0); cin.tie(0); ct(fixed); ct(setprecision(2)); 
    // int t;
    // cin >> t;
    // while(t--)
        solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 224 KB Output is correct
16 Correct 1 ms 224 KB Output is correct
17 Correct 0 ms 224 KB Output is correct
18 Correct 1 ms 224 KB Output is correct
19 Correct 0 ms 224 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 224 KB Output is correct
16 Correct 1 ms 224 KB Output is correct
17 Correct 0 ms 224 KB Output is correct
18 Correct 1 ms 224 KB Output is correct
19 Correct 0 ms 224 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 0 ms 212 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 0 ms 212 KB Output is correct
37 Correct 0 ms 224 KB Output is correct
38 Correct 1 ms 224 KB Output is correct
39 Correct 1 ms 224 KB Output is correct
40 Correct 0 ms 224 KB Output is correct
41 Correct 0 ms 224 KB Output is correct
42 Correct 1 ms 224 KB Output is correct
43 Correct 1 ms 224 KB Output is correct
44 Correct 0 ms 216 KB Output is correct
45 Correct 0 ms 212 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 0 ms 212 KB Output is correct
48 Correct 0 ms 212 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 0 ms 212 KB Output is correct
51 Correct 1 ms 212 KB Output is correct
52 Correct 1 ms 212 KB Output is correct
53 Correct 1 ms 212 KB Output is correct
54 Correct 1 ms 212 KB Output is correct
55 Correct 1 ms 212 KB Output is correct
56 Correct 0 ms 212 KB Output is correct
57 Correct 0 ms 212 KB Output is correct
58 Correct 1 ms 212 KB Output is correct
59 Correct 0 ms 224 KB Output is correct
60 Correct 0 ms 224 KB Output is correct
61 Correct 0 ms 224 KB Output is correct
62 Correct 1 ms 224 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 224 KB Output is correct
16 Correct 1 ms 224 KB Output is correct
17 Correct 0 ms 224 KB Output is correct
18 Correct 1 ms 224 KB Output is correct
19 Correct 0 ms 224 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 0 ms 212 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 0 ms 212 KB Output is correct
37 Correct 0 ms 224 KB Output is correct
38 Correct 1 ms 224 KB Output is correct
39 Correct 1 ms 224 KB Output is correct
40 Correct 0 ms 224 KB Output is correct
41 Correct 0 ms 224 KB Output is correct
42 Correct 1 ms 224 KB Output is correct
43 Correct 1 ms 224 KB Output is correct
44 Correct 0 ms 216 KB Output is correct
45 Correct 0 ms 212 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 0 ms 212 KB Output is correct
48 Correct 0 ms 212 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 0 ms 212 KB Output is correct
51 Correct 1 ms 212 KB Output is correct
52 Correct 1 ms 212 KB Output is correct
53 Correct 1 ms 212 KB Output is correct
54 Correct 1 ms 212 KB Output is correct
55 Correct 1 ms 212 KB Output is correct
56 Correct 0 ms 212 KB Output is correct
57 Correct 0 ms 212 KB Output is correct
58 Correct 1 ms 212 KB Output is correct
59 Correct 0 ms 224 KB Output is correct
60 Correct 0 ms 224 KB Output is correct
61 Correct 0 ms 224 KB Output is correct
62 Correct 1 ms 224 KB Output is correct
63 Correct 222 ms 8160 KB Output is correct
64 Correct 147 ms 8160 KB Output is correct
65 Correct 210 ms 8160 KB Output is correct
66 Correct 130 ms 8156 KB Output is correct
67 Correct 152 ms 8148 KB Output is correct
68 Correct 169 ms 8148 KB Output is correct
69 Correct 212 ms 8148 KB Output is correct
70 Correct 133 ms 8144 KB Output is correct
71 Correct 151 ms 8148 KB Output is correct
72 Correct 175 ms 8148 KB Output is correct
73 Correct 225 ms 8148 KB Output is correct
74 Correct 153 ms 8148 KB Output is correct
75 Correct 171 ms 8148 KB Output is correct
76 Correct 147 ms 8148 KB Output is correct
77 Correct 254 ms 8148 KB Output is correct
78 Correct 300 ms 8148 KB Output is correct
79 Correct 316 ms 8148 KB Output is correct
80 Correct 267 ms 8148 KB Output is correct
81 Correct 170 ms 8148 KB Output is correct
82 Correct 131 ms 8148 KB Output is correct
83 Correct 110 ms 8144 KB Output is correct
84 Correct 106 ms 8256 KB Output is correct
85 Correct 261 ms 8148 KB Output is correct
86 Correct 294 ms 8392 KB Output is correct
87 Correct 216 ms 20164 KB Output is correct
88 Correct 209 ms 20804 KB Output is correct