답안 #961705

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
961705 2024-04-12T10:55:55 Z Unforgettablepl 송금 (JOI19_remittance) C++17
15 / 100
1 ms 600 KB
    #include <bits/stdc++.h>
    using namespace std;

    #define int long long

    const int modulo = 1e9+7;

    int A[7];
    int B[7];
    int curr[7];
    int arr[7];

    int32_t main(){
        ios_base::sync_with_stdio(false);
        cin.tie(nullptr);
        int n;
        cin >> n;
        for(int i=0;i<n;i++)cin>>A[i]>>B[i];
        int start = 0;
        int power = 1;
        for(int i=1;i<n;i++){
            start+=power*(A[i]-B[i]);
            power*=2ll;
        }
        start+=power*(A[0]-B[0]);
        power*=2ll;
        power--;
        start/=power;
            arr[0]=start;
            bool works = true;
            if(start<0)works=false;
            for(int x=1;x<n;x++){
                arr[x]=arr[x-1]+A[x]-B[x];
                if(arr[x]<0)works=false;
                if(arr[x]&1)works=false;
                arr[x]/=2;
            }
            int backup = arr[n-1]+A[0]-B[0];
            if(backup&1)works=false;
            if(arr[0]!=backup/2)works=false;
            if(!works)goto shit;
            for(int x=0;x<n;x++)curr[x]=A[x];
            for(int rounds=1;rounds<40;rounds++){
                for(int x=0;x<n;x++){
                    int uses = min(arr[x],curr[x]/2);
                    curr[x]-=2*uses;
                    arr[x]-=uses;
                    curr[(x+1)%n]+=uses;
                }
            }
            for(int x=0;x<n;x++)if(curr[x]!=B[x])works=false;
            if(works){
                cout << "Yes\n";
                return 0;
            }
            shit:
        cout << "No\n";
    }
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 372 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 456 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 352 KB Output is correct
11 Correct 0 ms 356 KB Output is correct
12 Correct 0 ms 352 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 464 KB Output is correct
15 Correct 0 ms 352 KB Output is correct
16 Correct 0 ms 356 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 352 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 352 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 460 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 352 KB Output is correct
28 Correct 1 ms 352 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 600 KB Output is correct
31 Correct 1 ms 344 KB Output is correct
32 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 372 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 456 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 352 KB Output is correct
11 Correct 0 ms 356 KB Output is correct
12 Correct 0 ms 352 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 464 KB Output is correct
15 Correct 0 ms 352 KB Output is correct
16 Correct 0 ms 356 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 352 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 352 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 460 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 352 KB Output is correct
28 Correct 1 ms 352 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 600 KB Output is correct
31 Correct 1 ms 344 KB Output is correct
32 Correct 1 ms 344 KB Output is correct
33 Runtime error 1 ms 344 KB Execution killed with signal 11
34 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 372 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 456 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 352 KB Output is correct
11 Correct 0 ms 356 KB Output is correct
12 Correct 0 ms 352 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 464 KB Output is correct
15 Correct 0 ms 352 KB Output is correct
16 Correct 0 ms 356 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 352 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 352 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 460 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 352 KB Output is correct
28 Correct 1 ms 352 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 600 KB Output is correct
31 Correct 1 ms 344 KB Output is correct
32 Correct 1 ms 344 KB Output is correct
33 Runtime error 1 ms 344 KB Execution killed with signal 11
34 Halted 0 ms 0 KB -