109672024-04-22 17:17:08bovizdbSzitakötő (50 pont)cpp17Wrong answer 12/5017ms7092 KiB
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long
#define endl "\n"
#define pll pair<ll, ll>
#define fs first
#define sc second
#define vll vector<ll>
 
const ll mod = 1e9 + 7;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    ll n, k;
    cin >> n >> k;

    vll v(n);
    for (ll i = 0; i < n; i++)
        cin >> v[i];

    if (k == 1 && n > 1)
    {
        cout << 0;
        return 0;
    }

    ll ans = 1;

    vll w(n);
    w[0] = v[0];
    for (ll i = 1; i < n; i++)
        w[i] = w[i-1] + v[i];

    for (ll i = 0; i < k-1; i++)
    {
        if (w[i] <= w[k-1]-w[i])
        {
            ans *= 2;
            ans %= mod;
        }
    }

    for (ll i = k; i < n; i++)
    {
        if (w[i-1] <= v[i])
        {
            cout << 0;
            return 0;
        }
        if (w[i-1] > w[n-1]-w[i-1])
        {
            ans *= 2;
            ans %= mod;
        }
        else if (i < n-1)
        {
            if (w[i-1] > v[i] + v[i+1])
            {
                ans *= 2;
                ans %= mod;
            }
        }
        else
        {
            ans *= 2;
            ans %= 1000000007;
        }
    }
    if (k == n)
    {
        ans *= 2;
        ans %= mod;
    }
    cout << ans;

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base12/50
1Accepted0/03ms1828 KiB
2Wrong answer0/017ms5084 KiB
3Accepted1/13ms2232 KiB
4Accepted1/13ms2440 KiB
5Accepted1/13ms2660 KiB
6Accepted1/12ms2740 KiB
7Accepted1/12ms2744 KiB
8Wrong answer0/13ms2736 KiB
9Wrong answer0/13ms2960 KiB
10Wrong answer0/23ms2980 KiB
11Wrong answer0/23ms3180 KiB
12Wrong answer0/22ms3284 KiB
13Wrong answer0/23ms3420 KiB
14Accepted2/23ms3356 KiB
15Wrong answer0/23ms3364 KiB
16Wrong answer0/23ms3364 KiB
17Wrong answer0/23ms3508 KiB
18Wrong answer0/23ms3360 KiB
19Wrong answer0/23ms3364 KiB
20Wrong answer0/23ms3360 KiB
21Accepted1/13ms3488 KiB
22Wrong answer0/214ms6380 KiB
23Wrong answer0/214ms6424 KiB
24Wrong answer0/217ms6384 KiB
25Wrong answer0/217ms6392 KiB
26Accepted2/217ms6652 KiB
27Wrong answer0/212ms6844 KiB
28Wrong answer0/214ms6900 KiB
29Wrong answer0/214ms6948 KiB
30Wrong answer0/217ms6996 KiB
31Accepted2/217ms7092 KiB