답안 #367536

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
367536 2021-02-17T15:44:17 Z BartolM 송금 (JOI19_remittance) C++17
0 / 100
1 ms 504 KB
#include <bits/stdc++.h>

using namespace std;

#define X first
#define Y second
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <int, pii> pip;
typedef pair <pii, int> ppi;
typedef pair <ll, ll> pll;

const int INF=0x3f3f3f3f;
const int N=1e6+5;

int n;
ll A[N], B[N];
ll suma, sumb;

int main() {
    scanf("%d", &n);
    for (int i=0; i<n; ++i) {
        scanf("%lld %lld", A+i, B+i);
        sumb+=B[i]; suma+=A[i];
    }
//    if (!sumb) {
//        printf("%s\n", suma ? "No" : "Yes");
//        return 0;
//    }
    int ok=1;
    while (ok) {
        ok=0;
        for (int i=0; i<n; ++i) {
            if (A[i]<=B[i]) continue;
            ok=1;
            ll br=(A[i]-B[i]+1)/2;
            A[(i+1)%n]+=br;
            A[i]-=2*br;
            if (A[i]<0) {
                printf("No\n");
                return 0;
            }
        }
    }
    int res=1;
    for (int i=0; i<n; ++i) res&=A[i]==B[i];
    printf("%s\n", res ? "Yes" : "No");
    return 0;
}

Compilation message

remittance.cpp: In function 'int main()':
remittance.cpp:23:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   23 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
remittance.cpp:25:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   25 |         scanf("%lld %lld", A+i, B+i);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 504 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Incorrect 1 ms 364 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 504 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Incorrect 1 ms 364 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 504 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Incorrect 1 ms 364 KB Output isn't correct
5 Halted 0 ms 0 KB -