답안 #657216

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
657216 2022-11-09T08:39:54 Z sandry24 송금 (JOI19_remittance) C++17
100 / 100
528 ms 27468 KB
    #include <bits/stdc++.h>
    using namespace std;
     
    typedef long long ll;
    typedef vector<int> vi;
    typedef pair<int, int> pi;
    #define pb push_back
    #define mp make_pair
    #define f first
    #define s second
     
    bool is_equal(vector<pi> &a){
        bool equal = true;
        for(auto i : a)
            equal &= (i.f == i.s);
        return equal;
    }
     
    void solve(){
        int n;
        cin >> n;
        vector<pi> a(n);
        for(int i = 0; i < n; i++)
            cin >> a[i].f >> a[i].s;
        for(int i = 0; i < 50; i++){
            if(is_equal(a)){
                cout << "Yes\n";
                return;
            }
            for(int j = 0; j < n; j++){
                int diff = a[j].f - a[j].s;
                int next = (j == n-1 ? 0 : j+1);
                if(diff <= 0)
                    continue;
                if(diff % 2)
                    diff++;
                if(a[j].f < diff)
                    continue;
                a[next].f += diff/2;
                a[j].f -= diff;
            }
            //for(auto i : a)
                //cout << i.f << ' ' << i.s << '\n';
            //cout << '\n' << '\n';
        }
        cout << "No\n";
    }
     
    int main()
    {
        ios::sync_with_stdio(0); cin.tie(0);
        int t = 1;
        //cin >> t;
        while(t--){
            solve();
        }
    }
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 316 KB Output is correct
15 Correct 1 ms 320 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 320 KB Output is correct
21 Correct 1 ms 312 KB Output is correct
22 Correct 1 ms 324 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 320 KB Output is correct
25 Correct 1 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 1 ms 212 KB Output is correct
29 Correct 1 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 0 ms 212 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 316 KB Output is correct
15 Correct 1 ms 320 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 320 KB Output is correct
21 Correct 1 ms 312 KB Output is correct
22 Correct 1 ms 324 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 320 KB Output is correct
25 Correct 1 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 1 ms 212 KB Output is correct
29 Correct 1 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 1 ms 212 KB Output is correct
34 Correct 1 ms 260 KB Output is correct
35 Correct 1 ms 220 KB Output is correct
36 Correct 1 ms 220 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 1 ms 232 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 1 ms 316 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 1 ms 256 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 1 ms 324 KB Output is correct
48 Correct 0 ms 320 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 1 ms 224 KB Output is correct
51 Correct 1 ms 224 KB Output is correct
52 Correct 1 ms 224 KB Output is correct
53 Correct 1 ms 332 KB Output is correct
54 Correct 1 ms 320 KB Output is correct
55 Correct 1 ms 212 KB Output is correct
56 Correct 0 ms 212 KB Output is correct
57 Correct 1 ms 320 KB Output is correct
58 Correct 1 ms 212 KB Output is correct
59 Correct 1 ms 320 KB Output is correct
60 Correct 1 ms 212 KB Output is correct
61 Correct 1 ms 328 KB Output is correct
62 Correct 1 ms 324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 316 KB Output is correct
15 Correct 1 ms 320 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 320 KB Output is correct
21 Correct 1 ms 312 KB Output is correct
22 Correct 1 ms 324 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 320 KB Output is correct
25 Correct 1 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 1 ms 212 KB Output is correct
29 Correct 1 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 1 ms 212 KB Output is correct
34 Correct 1 ms 260 KB Output is correct
35 Correct 1 ms 220 KB Output is correct
36 Correct 1 ms 220 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 1 ms 232 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 1 ms 316 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 1 ms 256 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 1 ms 324 KB Output is correct
48 Correct 0 ms 320 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 1 ms 224 KB Output is correct
51 Correct 1 ms 224 KB Output is correct
52 Correct 1 ms 224 KB Output is correct
53 Correct 1 ms 332 KB Output is correct
54 Correct 1 ms 320 KB Output is correct
55 Correct 1 ms 212 KB Output is correct
56 Correct 0 ms 212 KB Output is correct
57 Correct 1 ms 320 KB Output is correct
58 Correct 1 ms 212 KB Output is correct
59 Correct 1 ms 320 KB Output is correct
60 Correct 1 ms 212 KB Output is correct
61 Correct 1 ms 328 KB Output is correct
62 Correct 1 ms 324 KB Output is correct
63 Correct 365 ms 27328 KB Output is correct
64 Correct 123 ms 11980 KB Output is correct
65 Correct 238 ms 26940 KB Output is correct
66 Correct 140 ms 11964 KB Output is correct
67 Correct 155 ms 13376 KB Output is correct
68 Correct 145 ms 15692 KB Output is correct
69 Correct 230 ms 27468 KB Output is correct
70 Correct 229 ms 11992 KB Output is correct
71 Correct 204 ms 13380 KB Output is correct
72 Correct 234 ms 15684 KB Output is correct
73 Correct 311 ms 27456 KB Output is correct
74 Correct 204 ms 11964 KB Output is correct
75 Correct 241 ms 13372 KB Output is correct
76 Correct 269 ms 15680 KB Output is correct
77 Correct 308 ms 27452 KB Output is correct
78 Correct 517 ms 19640 KB Output is correct
79 Correct 528 ms 19648 KB Output is correct
80 Correct 156 ms 19648 KB Output is correct
81 Correct 346 ms 19648 KB Output is correct
82 Correct 210 ms 11968 KB Output is correct
83 Correct 182 ms 11968 KB Output is correct
84 Correct 118 ms 11964 KB Output is correct
85 Correct 218 ms 8804 KB Output is correct
86 Correct 375 ms 8520 KB Output is correct
87 Correct 279 ms 8780 KB Output is correct
88 Correct 182 ms 8148 KB Output is correct