Submission #134469

# Submission time Handle Problem Language Result Execution time Memory
134469 2019-07-22T18:10:49 Z model_code Remittance (JOI19_remittance) C++17
100 / 100
391 ms 16136 KB
#include <cstdio>
#include <vector>
using namespace std;

int main()
{
  int n;
  scanf("%d",&n);
  vector<long long> A(n),B(n);
  for(int i=0;i<n;i++){
    scanf("%lld%lld",&A[i],&B[i]);
  }
  bool F,G=false;
  for(int i=0;i<n;i++){
    G|=(B[i]>0);
  }
  if(!G){
    F=true;
    for(int i=0;i<n;i++){
      F&=(A[i]==0);
    }
  }
  else{
    bool loop=true;
    while(loop){
      loop=false;
      for(int i=0;i<n;i++){
	if(A[i]>B[i]){
	  long long t=(A[i]-B[i]+1)/2;
	  A[i]-=2*t;
	  A[(i+1)%n]+=t;
	  loop=true;
	}
      }
    }
    F=true;
    for(int i=0;i<n;i++){
      F&=(A[i]==B[i]);
    }
  }
  puts(F?"Yes":"No");
  return 0;
}

Compilation message

remittance.cpp: In function 'int main()':
remittance.cpp:8:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&n);
   ~~~~~^~~~~~~~~
remittance.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld%lld",&A[i],&B[i]);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 380 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 256 KB Output is correct
18 Correct 2 ms 256 KB Output is correct
19 Correct 2 ms 256 KB Output is correct
20 Correct 2 ms 256 KB Output is correct
21 Correct 2 ms 256 KB Output is correct
22 Correct 2 ms 256 KB Output is correct
23 Correct 2 ms 256 KB Output is correct
24 Correct 2 ms 380 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2 ms 256 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 380 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 256 KB Output is correct
18 Correct 2 ms 256 KB Output is correct
19 Correct 2 ms 256 KB Output is correct
20 Correct 2 ms 256 KB Output is correct
21 Correct 2 ms 256 KB Output is correct
22 Correct 2 ms 256 KB Output is correct
23 Correct 2 ms 256 KB Output is correct
24 Correct 2 ms 380 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2 ms 256 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 256 KB Output is correct
33 Correct 2 ms 376 KB Output is correct
34 Correct 2 ms 256 KB Output is correct
35 Correct 2 ms 376 KB Output is correct
36 Correct 2 ms 376 KB Output is correct
37 Correct 2 ms 256 KB Output is correct
38 Correct 2 ms 376 KB Output is correct
39 Correct 2 ms 256 KB Output is correct
40 Correct 2 ms 376 KB Output is correct
41 Correct 2 ms 376 KB Output is correct
42 Correct 2 ms 376 KB Output is correct
43 Correct 2 ms 376 KB Output is correct
44 Correct 2 ms 256 KB Output is correct
45 Correct 2 ms 376 KB Output is correct
46 Correct 2 ms 376 KB Output is correct
47 Correct 2 ms 376 KB Output is correct
48 Correct 2 ms 376 KB Output is correct
49 Correct 2 ms 256 KB Output is correct
50 Correct 2 ms 376 KB Output is correct
51 Correct 2 ms 376 KB Output is correct
52 Correct 2 ms 256 KB Output is correct
53 Correct 2 ms 376 KB Output is correct
54 Correct 2 ms 256 KB Output is correct
55 Correct 2 ms 256 KB Output is correct
56 Correct 2 ms 256 KB Output is correct
57 Correct 2 ms 256 KB Output is correct
58 Correct 2 ms 380 KB Output is correct
59 Correct 2 ms 376 KB Output is correct
60 Correct 2 ms 376 KB Output is correct
61 Correct 2 ms 376 KB Output is correct
62 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 380 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 256 KB Output is correct
18 Correct 2 ms 256 KB Output is correct
19 Correct 2 ms 256 KB Output is correct
20 Correct 2 ms 256 KB Output is correct
21 Correct 2 ms 256 KB Output is correct
22 Correct 2 ms 256 KB Output is correct
23 Correct 2 ms 256 KB Output is correct
24 Correct 2 ms 380 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2 ms 256 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 256 KB Output is correct
33 Correct 2 ms 376 KB Output is correct
34 Correct 2 ms 256 KB Output is correct
35 Correct 2 ms 376 KB Output is correct
36 Correct 2 ms 376 KB Output is correct
37 Correct 2 ms 256 KB Output is correct
38 Correct 2 ms 376 KB Output is correct
39 Correct 2 ms 256 KB Output is correct
40 Correct 2 ms 376 KB Output is correct
41 Correct 2 ms 376 KB Output is correct
42 Correct 2 ms 376 KB Output is correct
43 Correct 2 ms 376 KB Output is correct
44 Correct 2 ms 256 KB Output is correct
45 Correct 2 ms 376 KB Output is correct
46 Correct 2 ms 376 KB Output is correct
47 Correct 2 ms 376 KB Output is correct
48 Correct 2 ms 376 KB Output is correct
49 Correct 2 ms 256 KB Output is correct
50 Correct 2 ms 376 KB Output is correct
51 Correct 2 ms 376 KB Output is correct
52 Correct 2 ms 256 KB Output is correct
53 Correct 2 ms 376 KB Output is correct
54 Correct 2 ms 256 KB Output is correct
55 Correct 2 ms 256 KB Output is correct
56 Correct 2 ms 256 KB Output is correct
57 Correct 2 ms 256 KB Output is correct
58 Correct 2 ms 380 KB Output is correct
59 Correct 2 ms 376 KB Output is correct
60 Correct 2 ms 376 KB Output is correct
61 Correct 2 ms 376 KB Output is correct
62 Correct 2 ms 256 KB Output is correct
63 Correct 387 ms 16120 KB Output is correct
64 Correct 185 ms 15992 KB Output is correct
65 Correct 370 ms 16136 KB Output is correct
66 Correct 184 ms 16120 KB Output is correct
67 Correct 198 ms 15992 KB Output is correct
68 Correct 223 ms 15992 KB Output is correct
69 Correct 391 ms 15992 KB Output is correct
70 Correct 190 ms 15992 KB Output is correct
71 Correct 199 ms 16028 KB Output is correct
72 Correct 223 ms 16032 KB Output is correct
73 Correct 389 ms 16024 KB Output is correct
74 Correct 181 ms 15992 KB Output is correct
75 Correct 198 ms 16120 KB Output is correct
76 Correct 231 ms 16120 KB Output is correct
77 Correct 377 ms 15992 KB Output is correct
78 Correct 264 ms 15992 KB Output is correct
79 Correct 259 ms 16112 KB Output is correct
80 Correct 267 ms 16020 KB Output is correct
81 Correct 277 ms 16028 KB Output is correct
82 Correct 166 ms 15992 KB Output is correct
83 Correct 164 ms 16012 KB Output is correct
84 Correct 160 ms 16016 KB Output is correct
85 Correct 319 ms 16056 KB Output is correct
86 Correct 315 ms 15992 KB Output is correct
87 Correct 222 ms 15992 KB Output is correct
88 Correct 227 ms 15992 KB Output is correct