답안 #431669

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
431669 2021-06-17T14:15:52 Z ScarletS 송금 (JOI19_remittance) C++17
0 / 100
1 ms 276 KB
#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
using namespace std;

const int N = 1e6+5;
int n, x, a[N][2], b[N][2];

void reset()
{
    for (int i=0;i<n;++i)
        for (int j=0;j<2;++j)
            b[i][j]=a[i][j];
}

bool solve(int k)
{
    for (int i=0;i<n*40;++i)
    {
        x=b[(k+i)%n][0]-b[(k+i)%n][1];
        if (x>0)
        {
            b[(k+i)%n][0]-=(x/2)*2;
            b[(k+i+1)%n][0]+=x/2;
        }
    }
    for (int i=0;i<n;++i)
        if (b[i][0]!=b[i][1])
            return 0;
    return 1;
}
  
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n;
    for (int i=0;i<n;++i)
        cin>>a[i][0]>>a[i][1];
    for (int i=0;i<n;++i)
    {
        reset();
        if (solve(i))
        {
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 276 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Incorrect 1 ms 204 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 276 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Incorrect 1 ms 204 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 276 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Incorrect 1 ms 204 KB Output isn't correct
9 Halted 0 ms 0 KB -