답안 #1102155

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1102155 2024-10-17T14:50:27 Z ro9669 송금 (JOI19_remittance) C++17
100 / 100
337 ms 16072 KB
#include <bits/stdc++.h>
#define fi first
#define se second
#define all(v) v.begin() , v.end()
#define sz(v) int(v.size())
#define unq(v) sort(all(v)); v.resize(unique(all(v)) - v.begin());
using namespace std;

typedef long long ll;
typedef pair<int , int> ii;
typedef pair<long long , int> lli;

const int maxN = int(1e6)+7;

int n;
ll a[maxN] , b[maxN];

bool check(){
    for (int i = 0 ; i < n ; i++){
        if (a[i] != b[i]) return 0;
    }
    return 1;
}

void solve(){
    cin >> n;
    for (int i = 0 ; i < n ; i++){
        cin >> a[i] >> b[i];
    }
    for (int t = 0 ; t < 30 ; t++){
        for (int i = 0 ; i < n ; i++){
            if (a[i] >= b[i]){
                ll x = (a[i] - b[i]) / 2;
                a[i] -= 2 * x;
                a[(i + 1) % n] += x;
            }
        }
    }
    for (int i = 0 ; i < n ; i++){
        if (a[i] < b[i]){
            cout << "No\n";
            return;
        }
    }
    if (check()){
        cout << "Yes\n";
        return;
    }
    bool ok = 0;
    for (int i = 0 ; i < n ; i++){
        if (a[i] == b[i]){
            cout << "No\n";
            return;
        }
        if (a[i] > 1) ok = 1;
    }
    if (ok) cout << "Yes\n"; else cout << "No\n";
}

#define name "A"

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    if (fopen(name".INP" , "r")){
        freopen(name".INP" , "r" , stdin);
        freopen(name".OUT" , "w" , stdout);
    }
    int t = 1; //cin >> t;
    while (t--) solve();
    return 0;
}

Compilation message

remittance.cpp: In function 'int main()':
remittance.cpp:65:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   65 |         freopen(name".INP" , "r" , stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
remittance.cpp:66:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   66 |         freopen(name".OUT" , "w" , stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 1 ms 2384 KB Output is correct
4 Correct 1 ms 2384 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 1 ms 2384 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
8 Correct 1 ms 2384 KB Output is correct
9 Correct 1 ms 2384 KB Output is correct
10 Correct 1 ms 2384 KB Output is correct
11 Correct 1 ms 2384 KB Output is correct
12 Correct 1 ms 2384 KB Output is correct
13 Correct 1 ms 2384 KB Output is correct
14 Correct 1 ms 2384 KB Output is correct
15 Correct 1 ms 2384 KB Output is correct
16 Correct 1 ms 2384 KB Output is correct
17 Correct 1 ms 2384 KB Output is correct
18 Correct 1 ms 2384 KB Output is correct
19 Correct 1 ms 2384 KB Output is correct
20 Correct 1 ms 2384 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2384 KB Output is correct
23 Correct 1 ms 2384 KB Output is correct
24 Correct 1 ms 2384 KB Output is correct
25 Correct 1 ms 2384 KB Output is correct
26 Correct 1 ms 2384 KB Output is correct
27 Correct 1 ms 2384 KB Output is correct
28 Correct 1 ms 2384 KB Output is correct
29 Correct 1 ms 2384 KB Output is correct
30 Correct 1 ms 2384 KB Output is correct
31 Correct 1 ms 2396 KB Output is correct
32 Correct 1 ms 2552 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 1 ms 2384 KB Output is correct
4 Correct 1 ms 2384 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 1 ms 2384 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
8 Correct 1 ms 2384 KB Output is correct
9 Correct 1 ms 2384 KB Output is correct
10 Correct 1 ms 2384 KB Output is correct
11 Correct 1 ms 2384 KB Output is correct
12 Correct 1 ms 2384 KB Output is correct
13 Correct 1 ms 2384 KB Output is correct
14 Correct 1 ms 2384 KB Output is correct
15 Correct 1 ms 2384 KB Output is correct
16 Correct 1 ms 2384 KB Output is correct
17 Correct 1 ms 2384 KB Output is correct
18 Correct 1 ms 2384 KB Output is correct
19 Correct 1 ms 2384 KB Output is correct
20 Correct 1 ms 2384 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2384 KB Output is correct
23 Correct 1 ms 2384 KB Output is correct
24 Correct 1 ms 2384 KB Output is correct
25 Correct 1 ms 2384 KB Output is correct
26 Correct 1 ms 2384 KB Output is correct
27 Correct 1 ms 2384 KB Output is correct
28 Correct 1 ms 2384 KB Output is correct
29 Correct 1 ms 2384 KB Output is correct
30 Correct 1 ms 2384 KB Output is correct
31 Correct 1 ms 2396 KB Output is correct
32 Correct 1 ms 2552 KB Output is correct
33 Correct 1 ms 2384 KB Output is correct
34 Correct 1 ms 2384 KB Output is correct
35 Correct 1 ms 2388 KB Output is correct
36 Correct 1 ms 2384 KB Output is correct
37 Correct 1 ms 2384 KB Output is correct
38 Correct 1 ms 2384 KB Output is correct
39 Correct 1 ms 2552 KB Output is correct
40 Correct 1 ms 2384 KB Output is correct
41 Correct 1 ms 2384 KB Output is correct
42 Correct 1 ms 2384 KB Output is correct
43 Correct 1 ms 2396 KB Output is correct
44 Correct 1 ms 2396 KB Output is correct
45 Correct 1 ms 2396 KB Output is correct
46 Correct 1 ms 2396 KB Output is correct
47 Correct 1 ms 2396 KB Output is correct
48 Correct 1 ms 2396 KB Output is correct
49 Correct 1 ms 2384 KB Output is correct
50 Correct 1 ms 2384 KB Output is correct
51 Correct 1 ms 2552 KB Output is correct
52 Correct 1 ms 2384 KB Output is correct
53 Correct 1 ms 2384 KB Output is correct
54 Correct 1 ms 2384 KB Output is correct
55 Correct 1 ms 2384 KB Output is correct
56 Correct 1 ms 2384 KB Output is correct
57 Correct 1 ms 2384 KB Output is correct
58 Correct 1 ms 2384 KB Output is correct
59 Correct 1 ms 2384 KB Output is correct
60 Correct 1 ms 2384 KB Output is correct
61 Correct 1 ms 2384 KB Output is correct
62 Correct 1 ms 2384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 1 ms 2384 KB Output is correct
4 Correct 1 ms 2384 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 1 ms 2384 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
8 Correct 1 ms 2384 KB Output is correct
9 Correct 1 ms 2384 KB Output is correct
10 Correct 1 ms 2384 KB Output is correct
11 Correct 1 ms 2384 KB Output is correct
12 Correct 1 ms 2384 KB Output is correct
13 Correct 1 ms 2384 KB Output is correct
14 Correct 1 ms 2384 KB Output is correct
15 Correct 1 ms 2384 KB Output is correct
16 Correct 1 ms 2384 KB Output is correct
17 Correct 1 ms 2384 KB Output is correct
18 Correct 1 ms 2384 KB Output is correct
19 Correct 1 ms 2384 KB Output is correct
20 Correct 1 ms 2384 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2384 KB Output is correct
23 Correct 1 ms 2384 KB Output is correct
24 Correct 1 ms 2384 KB Output is correct
25 Correct 1 ms 2384 KB Output is correct
26 Correct 1 ms 2384 KB Output is correct
27 Correct 1 ms 2384 KB Output is correct
28 Correct 1 ms 2384 KB Output is correct
29 Correct 1 ms 2384 KB Output is correct
30 Correct 1 ms 2384 KB Output is correct
31 Correct 1 ms 2396 KB Output is correct
32 Correct 1 ms 2552 KB Output is correct
33 Correct 1 ms 2384 KB Output is correct
34 Correct 1 ms 2384 KB Output is correct
35 Correct 1 ms 2388 KB Output is correct
36 Correct 1 ms 2384 KB Output is correct
37 Correct 1 ms 2384 KB Output is correct
38 Correct 1 ms 2384 KB Output is correct
39 Correct 1 ms 2552 KB Output is correct
40 Correct 1 ms 2384 KB Output is correct
41 Correct 1 ms 2384 KB Output is correct
42 Correct 1 ms 2384 KB Output is correct
43 Correct 1 ms 2396 KB Output is correct
44 Correct 1 ms 2396 KB Output is correct
45 Correct 1 ms 2396 KB Output is correct
46 Correct 1 ms 2396 KB Output is correct
47 Correct 1 ms 2396 KB Output is correct
48 Correct 1 ms 2396 KB Output is correct
49 Correct 1 ms 2384 KB Output is correct
50 Correct 1 ms 2384 KB Output is correct
51 Correct 1 ms 2552 KB Output is correct
52 Correct 1 ms 2384 KB Output is correct
53 Correct 1 ms 2384 KB Output is correct
54 Correct 1 ms 2384 KB Output is correct
55 Correct 1 ms 2384 KB Output is correct
56 Correct 1 ms 2384 KB Output is correct
57 Correct 1 ms 2384 KB Output is correct
58 Correct 1 ms 2384 KB Output is correct
59 Correct 1 ms 2384 KB Output is correct
60 Correct 1 ms 2384 KB Output is correct
61 Correct 1 ms 2384 KB Output is correct
62 Correct 1 ms 2384 KB Output is correct
63 Correct 337 ms 16012 KB Output is correct
64 Correct 134 ms 15948 KB Output is correct
65 Correct 237 ms 15944 KB Output is correct
66 Correct 138 ms 15944 KB Output is correct
67 Correct 147 ms 16028 KB Output is correct
68 Correct 148 ms 15944 KB Output is correct
69 Correct 198 ms 15944 KB Output is correct
70 Correct 135 ms 16028 KB Output is correct
71 Correct 141 ms 16024 KB Output is correct
72 Correct 147 ms 15956 KB Output is correct
73 Correct 196 ms 15944 KB Output is correct
74 Correct 132 ms 16012 KB Output is correct
75 Correct 140 ms 16008 KB Output is correct
76 Correct 142 ms 16020 KB Output is correct
77 Correct 199 ms 16008 KB Output is correct
78 Correct 155 ms 15944 KB Output is correct
79 Correct 156 ms 16008 KB Output is correct
80 Correct 154 ms 16024 KB Output is correct
81 Correct 163 ms 15944 KB Output is correct
82 Correct 123 ms 15952 KB Output is correct
83 Correct 79 ms 16016 KB Output is correct
84 Correct 124 ms 15944 KB Output is correct
85 Correct 190 ms 16072 KB Output is correct
86 Correct 188 ms 16016 KB Output is correct
87 Correct 157 ms 16012 KB Output is correct
88 Correct 158 ms 15956 KB Output is correct