답안 #1105081

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1105081 2024-10-25T09:56:13 Z VinhLuu 송금 (JOI19_remittance) C++17
100 / 100
257 ms 37316 KB
#include <bits/stdc++.h>
#define int long long
#define ll long long
using namespace std;

const int N = 1e6 + 5;
const int oo = 1e9;


int c[N], n, a[N], b[N];
bool f[N];

int st[N << 1];

void update(int i){
  i += n - 1;
  while(i > 1){
    i /= 2;
    if(c[st[i << 1]] >= c[st[i << 1|1]]) st[i] = st[i << 1];
    else st[i] = st[i << 1|1];
  }
}

signed main(){
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define task "v"
  if(fopen(task ".inp","r")){
    freopen(task ".inp","r",stdin);
    freopen(task ".out","w",stdout);
  }
  cin >> n;
  for(int i = 1; i <= n; i ++){
    cin >> a[i] >> b[i];
  }

  for(int time = 0; time <= 30; time ++){
    for(int i = 1; i <= n; i ++) if(a[i] >= b[i]){
      int val = (a[i] - b[i]) / 2;
      a[i] -= 2 * val;
      int nx = (i == n ? 1 : i + 1);
      a[nx] += val;
    }
  }

  bool ff = true, gg = true, vv = true;
  for(int i = 1; i <= n; i ++){
    if(a[i] < b[i]){
      cout << "No\n";
      return 0;
    }
    if(a[i] != b[i]) ff = false;
    if(a[i] == b[i]) vv = false;
    if(a[i] > 1) gg = false;
  }
  if(ff){
    cout << "Yes\n";
    return 0;
  }

  if(!gg && vv){
    cout << "Yes\n";
  }else cout << "No\n";

}

Compilation message

remittance.cpp: In function 'int main()':
remittance.cpp:28:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |     freopen(task ".inp","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
remittance.cpp:29:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |     freopen(task ".out","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6480 KB Output is correct
2 Correct 1 ms 6668 KB Output is correct
3 Correct 1 ms 6480 KB Output is correct
4 Correct 1 ms 6480 KB Output is correct
5 Correct 1 ms 6480 KB Output is correct
6 Correct 1 ms 6480 KB Output is correct
7 Correct 1 ms 6480 KB Output is correct
8 Correct 1 ms 6480 KB Output is correct
9 Correct 1 ms 6480 KB Output is correct
10 Correct 1 ms 6480 KB Output is correct
11 Correct 1 ms 6480 KB Output is correct
12 Correct 1 ms 6480 KB Output is correct
13 Correct 1 ms 6480 KB Output is correct
14 Correct 1 ms 6480 KB Output is correct
15 Correct 2 ms 6652 KB Output is correct
16 Correct 1 ms 6480 KB Output is correct
17 Correct 1 ms 6480 KB Output is correct
18 Correct 1 ms 6480 KB Output is correct
19 Correct 1 ms 6480 KB Output is correct
20 Correct 1 ms 6480 KB Output is correct
21 Correct 1 ms 6480 KB Output is correct
22 Correct 1 ms 6480 KB Output is correct
23 Correct 1 ms 6480 KB Output is correct
24 Correct 1 ms 6480 KB Output is correct
25 Correct 1 ms 6480 KB Output is correct
26 Correct 1 ms 6480 KB Output is correct
27 Correct 1 ms 6612 KB Output is correct
28 Correct 1 ms 6480 KB Output is correct
29 Correct 1 ms 6480 KB Output is correct
30 Correct 1 ms 6480 KB Output is correct
31 Correct 1 ms 6480 KB Output is correct
32 Correct 1 ms 6480 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6480 KB Output is correct
2 Correct 1 ms 6668 KB Output is correct
3 Correct 1 ms 6480 KB Output is correct
4 Correct 1 ms 6480 KB Output is correct
5 Correct 1 ms 6480 KB Output is correct
6 Correct 1 ms 6480 KB Output is correct
7 Correct 1 ms 6480 KB Output is correct
8 Correct 1 ms 6480 KB Output is correct
9 Correct 1 ms 6480 KB Output is correct
10 Correct 1 ms 6480 KB Output is correct
11 Correct 1 ms 6480 KB Output is correct
12 Correct 1 ms 6480 KB Output is correct
13 Correct 1 ms 6480 KB Output is correct
14 Correct 1 ms 6480 KB Output is correct
15 Correct 2 ms 6652 KB Output is correct
16 Correct 1 ms 6480 KB Output is correct
17 Correct 1 ms 6480 KB Output is correct
18 Correct 1 ms 6480 KB Output is correct
19 Correct 1 ms 6480 KB Output is correct
20 Correct 1 ms 6480 KB Output is correct
21 Correct 1 ms 6480 KB Output is correct
22 Correct 1 ms 6480 KB Output is correct
23 Correct 1 ms 6480 KB Output is correct
24 Correct 1 ms 6480 KB Output is correct
25 Correct 1 ms 6480 KB Output is correct
26 Correct 1 ms 6480 KB Output is correct
27 Correct 1 ms 6612 KB Output is correct
28 Correct 1 ms 6480 KB Output is correct
29 Correct 1 ms 6480 KB Output is correct
30 Correct 1 ms 6480 KB Output is correct
31 Correct 1 ms 6480 KB Output is correct
32 Correct 1 ms 6480 KB Output is correct
33 Correct 1 ms 6480 KB Output is correct
34 Correct 1 ms 6480 KB Output is correct
35 Correct 1 ms 6480 KB Output is correct
36 Correct 1 ms 6616 KB Output is correct
37 Correct 1 ms 6628 KB Output is correct
38 Correct 2 ms 6480 KB Output is correct
39 Correct 1 ms 6480 KB Output is correct
40 Correct 1 ms 6480 KB Output is correct
41 Correct 1 ms 6648 KB Output is correct
42 Correct 2 ms 6608 KB Output is correct
43 Correct 1 ms 6480 KB Output is correct
44 Correct 1 ms 6480 KB Output is correct
45 Correct 1 ms 6480 KB Output is correct
46 Correct 1 ms 6480 KB Output is correct
47 Correct 1 ms 6480 KB Output is correct
48 Correct 1 ms 6480 KB Output is correct
49 Correct 1 ms 6612 KB Output is correct
50 Correct 1 ms 6480 KB Output is correct
51 Correct 1 ms 6480 KB Output is correct
52 Correct 1 ms 6480 KB Output is correct
53 Correct 2 ms 6480 KB Output is correct
54 Correct 2 ms 6480 KB Output is correct
55 Correct 2 ms 6480 KB Output is correct
56 Correct 1 ms 6480 KB Output is correct
57 Correct 1 ms 6480 KB Output is correct
58 Correct 1 ms 6480 KB Output is correct
59 Correct 1 ms 6480 KB Output is correct
60 Correct 1 ms 6620 KB Output is correct
61 Correct 1 ms 6480 KB Output is correct
62 Correct 1 ms 6480 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6480 KB Output is correct
2 Correct 1 ms 6668 KB Output is correct
3 Correct 1 ms 6480 KB Output is correct
4 Correct 1 ms 6480 KB Output is correct
5 Correct 1 ms 6480 KB Output is correct
6 Correct 1 ms 6480 KB Output is correct
7 Correct 1 ms 6480 KB Output is correct
8 Correct 1 ms 6480 KB Output is correct
9 Correct 1 ms 6480 KB Output is correct
10 Correct 1 ms 6480 KB Output is correct
11 Correct 1 ms 6480 KB Output is correct
12 Correct 1 ms 6480 KB Output is correct
13 Correct 1 ms 6480 KB Output is correct
14 Correct 1 ms 6480 KB Output is correct
15 Correct 2 ms 6652 KB Output is correct
16 Correct 1 ms 6480 KB Output is correct
17 Correct 1 ms 6480 KB Output is correct
18 Correct 1 ms 6480 KB Output is correct
19 Correct 1 ms 6480 KB Output is correct
20 Correct 1 ms 6480 KB Output is correct
21 Correct 1 ms 6480 KB Output is correct
22 Correct 1 ms 6480 KB Output is correct
23 Correct 1 ms 6480 KB Output is correct
24 Correct 1 ms 6480 KB Output is correct
25 Correct 1 ms 6480 KB Output is correct
26 Correct 1 ms 6480 KB Output is correct
27 Correct 1 ms 6612 KB Output is correct
28 Correct 1 ms 6480 KB Output is correct
29 Correct 1 ms 6480 KB Output is correct
30 Correct 1 ms 6480 KB Output is correct
31 Correct 1 ms 6480 KB Output is correct
32 Correct 1 ms 6480 KB Output is correct
33 Correct 1 ms 6480 KB Output is correct
34 Correct 1 ms 6480 KB Output is correct
35 Correct 1 ms 6480 KB Output is correct
36 Correct 1 ms 6616 KB Output is correct
37 Correct 1 ms 6628 KB Output is correct
38 Correct 2 ms 6480 KB Output is correct
39 Correct 1 ms 6480 KB Output is correct
40 Correct 1 ms 6480 KB Output is correct
41 Correct 1 ms 6648 KB Output is correct
42 Correct 2 ms 6608 KB Output is correct
43 Correct 1 ms 6480 KB Output is correct
44 Correct 1 ms 6480 KB Output is correct
45 Correct 1 ms 6480 KB Output is correct
46 Correct 1 ms 6480 KB Output is correct
47 Correct 1 ms 6480 KB Output is correct
48 Correct 1 ms 6480 KB Output is correct
49 Correct 1 ms 6612 KB Output is correct
50 Correct 1 ms 6480 KB Output is correct
51 Correct 1 ms 6480 KB Output is correct
52 Correct 1 ms 6480 KB Output is correct
53 Correct 2 ms 6480 KB Output is correct
54 Correct 2 ms 6480 KB Output is correct
55 Correct 2 ms 6480 KB Output is correct
56 Correct 1 ms 6480 KB Output is correct
57 Correct 1 ms 6480 KB Output is correct
58 Correct 1 ms 6480 KB Output is correct
59 Correct 1 ms 6480 KB Output is correct
60 Correct 1 ms 6620 KB Output is correct
61 Correct 1 ms 6480 KB Output is correct
62 Correct 1 ms 6480 KB Output is correct
63 Correct 257 ms 36168 KB Output is correct
64 Correct 103 ms 20548 KB Output is correct
65 Correct 170 ms 35584 KB Output is correct
66 Correct 116 ms 20696 KB Output is correct
67 Correct 116 ms 22088 KB Output is correct
68 Correct 122 ms 24532 KB Output is correct
69 Correct 168 ms 36044 KB Output is correct
70 Correct 116 ms 20552 KB Output is correct
71 Correct 113 ms 22088 KB Output is correct
72 Correct 131 ms 24396 KB Output is correct
73 Correct 184 ms 36168 KB Output is correct
74 Correct 104 ms 20692 KB Output is correct
75 Correct 116 ms 22088 KB Output is correct
76 Correct 118 ms 24400 KB Output is correct
77 Correct 172 ms 36168 KB Output is correct
78 Correct 131 ms 28504 KB Output is correct
79 Correct 129 ms 28488 KB Output is correct
80 Correct 132 ms 28500 KB Output is correct
81 Correct 133 ms 28256 KB Output is correct
82 Correct 103 ms 20692 KB Output is correct
83 Correct 112 ms 20788 KB Output is correct
84 Correct 97 ms 20820 KB Output is correct
85 Correct 169 ms 37316 KB Output is correct
86 Correct 185 ms 37200 KB Output is correct
87 Correct 134 ms 29512 KB Output is correct
88 Correct 139 ms 29516 KB Output is correct