Submission #211613

# Submission time Handle Problem Language Result Execution time Memory
211613 2020-03-20T20:13:22 Z m3r8 Remittance (JOI19_remittance) C++14
0 / 100
4 ms 384 KB
#include <stdio.h>

#define N 1000100
#define ll long long

ll A[N];
ll B[N];
int cnt[N];

int main(void){
  int n;
  scanf("%d",&n);
  for(int i = 0;i<n;i++){
    scanf("%lld %lld",&A[i],&B[i]);  
  };
  for(int j = 0;j<2;j++){
    for(int i = 0;i<n;i++){
      if(A[i] > B[i]){
        ll tmp = A[i]-B[i];
        if(tmp % 2)tmp--;
        tmp /= 2;
        A[(i+1)%n] += tmp; 
        A[i] -= tmp * 2;
      };  
    };
  };
  int pos = 1;
  for(int i = 0;i<n;i++){
    ll diff = A[i]-B[i];  
    pos = diff >= 0;
    if(!pos)break;
    for(int j = 0;j<32;j++){
      if(diff & (1ull << j)){
        cnt[(i+j)%n] ^= 1;
      };
    };
  };
  if(pos){
    int st = cnt[0];
    for(int i = 0;i<n;i++){
      if(cnt[i] != st){
        pos = 0;  
        break;
      };
      if(cnt[i] && B[i] == 0){
        pos = 0;  
        break;
      };
    };
  };
  if(pos)printf("Yes\n");
  else printf("No\n");
  return 0;
};

Compilation message

remittance.cpp: In function 'int main()':
remittance.cpp:12:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&n);
   ~~~~~^~~~~~~~~
remittance.cpp:14: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 4 ms 256 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 4 ms 256 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 4 ms 256 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Incorrect 4 ms 256 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 4 ms 256 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 4 ms 256 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Incorrect 4 ms 256 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 4 ms 256 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 4 ms 256 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Incorrect 4 ms 256 KB Output isn't correct
9 Halted 0 ms 0 KB -