Submission #773854

# Submission time Handle Problem Language Result Execution time Memory
773854 2023-07-05T09:09:32 Z gagik_2007 Remittance (JOI19_remittance) C++17
15 / 100
1 ms 324 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef pair<ll, ll> pll;

#define ff first
#define ss second

ll ttt;
const ll INF=1e18;
const ll MOD=1e9+7;
const ll N=3e5+7;
ll n,m,k;
vector<ll>a,b;

void change(ll i, ll tal){
    i%=n;
    for(ll j=0;j<7*n;j+=n){
        a[i+j]-=tal*2;
        a[(i+1)%n+j]+=tal;
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    // freopen("output.txt","w",stdout);
    cin>>n;
    for(ll i=0;i<n;i++){
        ll x,y;
        cin>>x>>y;
        a.push_back(x);
        b.push_back(y);
    }
    for(ll i=0;i<6*n;i++){
        a.push_back(a[i]);
        b.push_back(b[i]);
    }
    for(ll i=0;i<7*n;i++){
        if(a[i]!=b[i]){
            ll tal=0;
            if(a[i]!=1&&a[i]>b[i]){
                if(a[i]%2==b[i]%2){
                    tal=(a[i]-b[i])/2;
                }
                else{
                    tal=(a[i]-b[i]+1)/2;
                    if(b[i]==0){
                        tal--;
                    }
                }
            }
            // cout<<i%n<<": "<<a[i]<<", "<<b[i]<<": "<<tal<<endl;
            change(i,tal);
        }
    }
    for(ll i=0;i<n;i++){
        // cout<<a[i]<<" "<<b[i]<<endl;
        if(a[i]!=b[i]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 232 KB Output is correct
5 Correct 1 ms 228 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 324 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 324 KB Output is correct
11 Correct 0 ms 324 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 288 KB Output is correct
16 Correct 0 ms 316 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 312 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 0 ms 320 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Correct 1 ms 316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 232 KB Output is correct
5 Correct 1 ms 228 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 324 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 324 KB Output is correct
11 Correct 0 ms 324 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 288 KB Output is correct
16 Correct 0 ms 316 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 312 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 0 ms 320 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Correct 1 ms 316 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 1 ms 320 KB Output is correct
35 Correct 0 ms 212 KB Output is correct
36 Incorrect 1 ms 212 KB Output isn't correct
37 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 232 KB Output is correct
5 Correct 1 ms 228 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 324 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 324 KB Output is correct
11 Correct 0 ms 324 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 288 KB Output is correct
16 Correct 0 ms 316 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 312 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 0 ms 320 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Correct 1 ms 316 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 1 ms 320 KB Output is correct
35 Correct 0 ms 212 KB Output is correct
36 Incorrect 1 ms 212 KB Output isn't correct
37 Halted 0 ms 0 KB -