Submission #431622

# Submission time Handle Problem Language Result Execution time Memory
431622 2021-06-17T13:41:28 Z ScarletS Remittance (JOI19_remittance) C++17
0 / 100
2 ms 204 KB
#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
using namespace std;

int a[1<<20][2];
priority_queue<array<int,2>> o,e;

void add(int i)
{
    if (a[i][0]>a[i][1])
    {
        if ((a[i][0]-a[i][1])&1)
            o.push({a[i][0]-a[i][1],i});
        else
            e.push({a[i][0]-a[i][1],i});
    }
}
  
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n,x,y;
    cin>>n;
    for (int i=0;i<n;++i)
    {
        cin>>a[i][0]>>a[i][1];
        add(i);
    }
    while (!e.empty())
    {
        x=e.top()[0];
        y=e.top()[1];
        e.pop();
        if (a[y][0]-a[y][1]!=x)
            continue;
        a[(y+1)%n][0]+=x/2;
        a[y][0]=a[y][1];
        add((y+1)%n);
    }
    for (int i=0;i<n;++i)
        if (a[i][0]!=a[i][1])
        {
            cout<<"No";
            return 0;
        }
    cout<<"Yes";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 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 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 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 -
# Verdict Execution time Memory Grader output
1 Correct 2 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 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 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 -
# Verdict Execution time Memory Grader output
1 Correct 2 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 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 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 -