Submission #570386

# Submission time Handle Problem Language Result Execution time Memory
570386 2022-05-29T12:30:41 Z urd05 Remittance (JOI19_remittance) C++17
0 / 100
0 ms 212 KB
#include <bits/stdc++.h>
using namespace std;
 
int n;
long long c[1000001];
long long arr[1000001]; //비트 저장
long long value[1000001];
long long money[1000001];
bool vis[1000001];
 
int main() {
    scanf("%d",&n);
    for(int i=1;i<=n;i++) {
        int a,b;
        scanf("%d %d",&a,&b);
        money[i]=a;
        c[i]=b-a;
    }
    long long val=0;
    for(int i=0;i<n;i++) {
        val+=(c[i+1]<<i);
    }
    if (val%((1<<n)-1)!=0) {
        printf("%lld",val);
    }
    long long x=-val/((1<<n)-1);
    value[n]=x;
    if (x<0) {
        printf("No");
        return 0;
    }
    for(int i=n-1;i>0;i--) {
        x=2*x+c[i+1];
        value[i]=x;
        if (x<0) {
            printf("No");
            return 0;
        }
    }
    printf("Yes");
    return 0;
}

Compilation message

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