제출 #211635

#제출 시각아이디문제언어결과실행 시간메모리
211635m3r8송금 (JOI19_remittance)C++14
100 / 100
380 ms36472 KiB
#include <stdio.h>

#define N 1000100
#define ll long long

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

int main(void){
  int n;
  int nn = 1;
  int nnn = 1;
  scanf("%d",&n);
  for(int i = 0;i<n;i++){
    scanf("%lld %lld",&A[i],&B[i]);  
    if(B[i] != 0)nn = 0;
    if(A[i] != 0)nnn = 0;
  };
  int pos = 1;
  if(nn && !nnn)pos = 0;
  if(pos){
    int end = 1;
    while(end){
      end = 0;
      for(int i = 0;i<n;i++){
        if(A[i] > B[i]){
          ll diff = A[i] - B[i];
          if(diff % 2)diff++;
          if(A[i] >= diff){
            end = 1;  
            A[i] -= diff;
            A[(i+1)%n] += diff/2;
          };
        };
      };
    };
    for(int i = 0;i<n;i++){
      if(A[i] != B[i]){
        pos = 0;  
        break;
      };
    };
  };
  if(pos)printf("Yes\n");
  else printf("No\n");
  return 0;
};

컴파일 시 표준 에러 (stderr) 메시지

remittance.cpp: In function 'int main()':
remittance.cpp:14:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&n);
   ~~~~~^~~~~~~~~
remittance.cpp:16: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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...