답안 #140470

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
140470 2019-08-03T08:03:24 Z blue 송금 (JOI19_remittance) C++11
0 / 100
2 ms 380 KB
#include <iostream>
using namespace std;

int main()
{
    int n;
    cin >> n;
    
    int A[n], B[n];
    int s, sv = -2000000000;
    for(int i = 0; i < n; i++) 
    {
        cin >> A[i] >> B[i];
        
        if(A[i] - B[i] > sv)
        {
            sv = A[i] - B[i];
            s = i;
        }
    }
    if(sv < 0) 
    {
        cout << "No\n";
        return 0;
    }
    for(int t = 1; t <= 20; t++)
    {
        if(A[s] - B[s] > 1)
        {
            A[(s+1) % n] += (A[s] - B[s]) / 2;
            A[s] -= 2*((A[s] - B[s]) / 2);
        }
        for(int i = (s+1)%n; i != s; i = (i+1)%n)
        {
            if(A[i] - B[i] <= 0) continue;
            A[(i+1)%n] += (A[i] - B[i]) / 2;
            A[i] -= 2*((A[i] - B[i]) / 2);
        }
    }
    for(int i = 0; i < n; i++)
    {
        if(A[i] == B[i]) continue;
        cout << "No\n";
        return 0;
    }
    cout << "Yes\n";
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Incorrect 2 ms 376 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Incorrect 2 ms 376 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Incorrect 2 ms 376 KB Output isn't correct
9 Halted 0 ms 0 KB -