Submission #677918

# Submission time Handle Problem Language Result Execution time Memory
677918 2023-01-04T15:50:07 Z qwerasdfzxcl Remittance (JOI19_remittance) C++17
0 / 100
1 ms 212 KB
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
constexpr int INF = 1e9+100;
int n;

void NO(){
    printf("No\n");
    exit(0);
}

int s[2002000];
void add(ll x, int p){
    for (int i=0;i<60;i++) if (x&(1LL<<i)){
        s[p+i]++;
    }

    for (int i=p;;i++){
        if (s[i] > 1){
            s[i+1] += s[i]/2;
            s[i] %= 2;
        }

        else if (i-p > 60) break;
    }

    //for (int i=10;i>=0;i--) printf("%d", s[i]);
    //printf("\n");
}

ll getq(vector<int> a, vector<int> b){
    for (int i=0;i<n;i++){
        ll x = a[i] - b[i] + INF;
        add(x, i);
    }

    ll tmp = 0;
    for (int j=0;j<40;j++){
        if (s[j+n]) tmp |= 1LL<<j;
    }
    add(tmp+1, 0);

    //printf("ok\n");
    for (int i=0;i<n;i++) if (s[i]) return -1;
    //printf("ok\n");
    return tmp+1 - INF;
}

int main(){
    scanf("%d", &n);
    vector<int> a, b;
    int bb = 0;
    for (int i=0;i<n;i++){
        int x, y;
        scanf("%d %d", &x, &y);
        a.push_back(x);
        b.push_back(y);

        bb |= y;
    }

    if (bb==0) NO();

    ll q;
    for (int i=0;i<n;i++){
        if (!i){
            q = getq(a, b);
            if (q==-1) NO();
        }

        else q = (q+a[i-1]-b[i-1])/2;

        //printf("%lld\n", q);
        if (q<0) NO();

        //rotate(a.begin(), a.begin()+1, a.end());
        //rotate(b.begin(), b.begin()+1, b.end());
    }

    printf("Yes\n");
    return 0;
}

Compilation message

remittance.cpp: In function 'int main()':
remittance.cpp:51:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   51 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
remittance.cpp:56:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   56 |         scanf("%d %d", &x, &y);
      |         ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -