Submission #134468

# Submission time Handle Problem Language Result Execution time Memory
134468 2019-07-22T18:10:35 Z model_code Remittance (JOI19_remittance) C++17
100 / 100
418 ms 39620 KB
#include <cstdio>
#include <vector>

using namespace std;

int main()
{
  int n;
  scanf("%d",&n);
  vector<vector<long long> > A(2,vector<long long>(n));
  for(int i=0;i<n;i++){
    scanf("%lld%lld",&A[0][i],&A[1][i]);
  }
  bool ans=true;
  bool F=true;
  for(int i=0;i<n;i++){
    if(A[1][i]>0){
      F=false;
    }
  }
  if(F){
    for(int i=0;i<n;i++){
      if(A[0][i]>0){
	ans=false;
      }
    }
  }
  vector<vector<long long> > b(2,vector<long long>(n));
  long long  K[2];
  for(int t=0;t<2;t++){
    for(int i=0;i<n;i++){
      b[t][i]=A[t][i];
    }
    K[t]=0ll;
    long long r=0ll;
    do{
      for(int i=0;i<n;i++){
	long long T=b[t][i]+r;
	b[t][i]=T%2;
	r=T/2;
      }
      K[t]+=r;
    }while(r>0);
    bool F=true;
    for(int i=0;i<n;i++){
      if(b[t][i]==0){
	F=false;
      }
    }
    if(F){
      K[t]++;
      for(int i=0;i<n;i++){
	b[t][i]=0;
      }
    }
  }
  for(int i=0;i<n;i++){
    if(b[0][i]!=b[1][i]){
      ans=false;
    }
  }
  long long x=K[0]-K[1];
  if(x<0){
    ans=false;
  }
  for(int i=n-1;i>=0;i--){
    x=A[1][i]-A[0][i]+2*x;
    if(x<0){
      ans=false;
    }
  }
  puts(ans?"Yes":"No");
  return 0;
}

Compilation message

remittance.cpp: In function 'int main()':
remittance.cpp:9:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&n);
   ~~~~~^~~~~~~~~
remittance.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld%lld",&A[0][i],&A[1][i]);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 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 252 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 252 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 256 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 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 380 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 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 256 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 256 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 256 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 252 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 252 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 256 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 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 380 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 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 256 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 256 KB Output is correct
32 Correct 2 ms 256 KB Output is correct
33 Correct 2 ms 256 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 252 KB Output is correct
37 Correct 2 ms 256 KB Output is correct
38 Correct 2 ms 256 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 256 KB Output is correct
42 Correct 2 ms 252 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 256 KB Output is correct
47 Correct 2 ms 376 KB Output is correct
48 Correct 2 ms 256 KB Output is correct
49 Correct 2 ms 376 KB Output is correct
50 Correct 2 ms 376 KB Output is correct
51 Correct 1 ms 380 KB Output is correct
52 Correct 2 ms 380 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 376 KB Output is correct
56 Correct 2 ms 376 KB Output is correct
57 Correct 2 ms 376 KB Output is correct
58 Correct 2 ms 256 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 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 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 252 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 252 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 256 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 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 380 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 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 256 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 256 KB Output is correct
32 Correct 2 ms 256 KB Output is correct
33 Correct 2 ms 256 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 252 KB Output is correct
37 Correct 2 ms 256 KB Output is correct
38 Correct 2 ms 256 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 256 KB Output is correct
42 Correct 2 ms 252 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 256 KB Output is correct
47 Correct 2 ms 376 KB Output is correct
48 Correct 2 ms 256 KB Output is correct
49 Correct 2 ms 376 KB Output is correct
50 Correct 2 ms 376 KB Output is correct
51 Correct 1 ms 380 KB Output is correct
52 Correct 2 ms 380 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 376 KB Output is correct
56 Correct 2 ms 376 KB Output is correct
57 Correct 2 ms 376 KB Output is correct
58 Correct 2 ms 256 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 376 KB Output is correct
63 Correct 412 ms 39452 KB Output is correct
64 Correct 214 ms 39444 KB Output is correct
65 Correct 400 ms 39444 KB Output is correct
66 Correct 211 ms 39524 KB Output is correct
67 Correct 228 ms 39440 KB Output is correct
68 Correct 254 ms 39520 KB Output is correct
69 Correct 407 ms 39492 KB Output is correct
70 Correct 206 ms 39492 KB Output is correct
71 Correct 233 ms 39492 KB Output is correct
72 Correct 259 ms 39524 KB Output is correct
73 Correct 414 ms 39620 KB Output is correct
74 Correct 207 ms 39520 KB Output is correct
75 Correct 232 ms 39524 KB Output is correct
76 Correct 256 ms 39444 KB Output is correct
77 Correct 418 ms 39484 KB Output is correct
78 Correct 291 ms 39524 KB Output is correct
79 Correct 294 ms 39452 KB Output is correct
80 Correct 297 ms 39520 KB Output is correct
81 Correct 294 ms 39520 KB Output is correct
82 Correct 201 ms 39392 KB Output is correct
83 Correct 209 ms 39480 KB Output is correct
84 Correct 193 ms 39396 KB Output is correct
85 Correct 348 ms 39520 KB Output is correct
86 Correct 347 ms 39524 KB Output is correct
87 Correct 265 ms 39520 KB Output is correct
88 Correct 263 ms 39440 KB Output is correct