115112024-10-15 12:01:13chucknorrisSzitakötő (50 pont)cpp17Wrong answer 9/5048ms1480 KiB
#include <iostream>
#define MOD 1000000007

using namespace std;

int N, K, a[100002];
long long s[100002];

int main(){
    cin >> N >> K;
    for(int i = 1; i <= N; i++){
        cin >> a[i]; s[i] = s[i - 1] + a[i];
    }

    if(N == 1) cout << 2;
    else if(K == 1) cout << 0;
    else if(N == 3){
        if(K == 2){
            if(a[1] + a[2] < a[3]) cout << 0;
            else cout << 4;
        }
        else if(K == 3){
            if(a[1] + a[2] <= a[3]) cout << 8;
            else cout << 4;
        }
    }
    else{
        for(int i = K; i < N; i++){
            if(s[i] <= a[i + 1]){
                cout << 0; return 0;
            }
        }
        long long ans = 1, S = 0;
        int i = K;
        while(S < s[i]){
            S = S + a[i]; i = i - 1;
        }

        for( ; i >= 1; i--) ans = ans * 2 % MOD;

        if(K == N) {cout << ans * 2 % MOD; return 0;}


    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base9/50
1Wrong answer0/01ms320 KiB
2Wrong answer0/048ms1400 KiB
3Accepted1/11ms508 KiB
4Accepted1/11ms320 KiB
5Wrong answer0/11ms320 KiB
6Accepted1/11ms320 KiB
7Accepted1/11ms320 KiB
8Wrong answer0/11ms320 KiB
9Wrong answer0/11ms320 KiB
10Wrong answer0/21ms320 KiB
11Wrong answer0/21ms320 KiB
12Wrong answer0/21ms320 KiB
13Wrong answer0/21ms320 KiB
14Wrong answer0/22ms320 KiB
15Wrong answer0/22ms320 KiB
16Wrong answer0/22ms320 KiB
17Wrong answer0/21ms520 KiB
18Wrong answer0/21ms320 KiB
19Wrong answer0/21ms320 KiB
20Wrong answer0/21ms500 KiB
21Accepted1/11ms320 KiB
22Wrong answer0/234ms1328 KiB
23Wrong answer0/235ms1360 KiB
24Wrong answer0/246ms1452 KiB
25Wrong answer0/248ms1440 KiB
26Accepted2/246ms1336 KiB
27Wrong answer0/218ms1336 KiB
28Wrong answer0/235ms1432 KiB
29Wrong answer0/232ms1336 KiB
30Wrong answer0/246ms1336 KiB
31Accepted2/243ms1480 KiB