Submission #284171

# Submission time Handle Problem Language Result Execution time Memory
284171 2020-08-27T00:36:46 Z jainbot27 Remittance (JOI19_remittance) C++17
0 / 100
0 ms 256 KB
#include <bits/stdc++.h>
using namespace std;
#define m max_element
int main(){
    int n;scanf("%d",&n);vector<int>a(n),b(n);
    for(int i=0;i<n;i++)scanf("%d%d",&a[i],&b[i]);
    if(*m(b.begin(),b.end())==0){
        puts(*m(a.begin(),a.end())==0?"YES":"NO");exit(0);
    }
    int g=1;
    while(g){
        g=0;
        for(int i=0;i<n;i++){
            if(a[i]>b[i]){
                int r=(a[i]-b[i]+1)/2;
                a[(i+1)%n]+=r;
                a[i]-=r*2; 
                g=1;
            }
        }
    }
    g=1;
    for(int i=0; i < n; i++){
        g&=a[i]==b[i];
    }
    puts(g?"YES":"NO");
}

Compilation message

remittance.cpp: In function 'int main()':
remittance.cpp:5:16: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    5 |     int n;scanf("%d",&n);vector<int>a(n),b(n);
      |           ~~~~~^~~~~~~~~
remittance.cpp:6:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    6 |     for(int i=0;i<n;i++)scanf("%d%d",&a[i],&b[i]);
      |                         ~~~~~^~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -