109662024-04-22 17:01:22bovizdbSzitakötő (50 pont)cpp17Wrong answer 12/5018ms7176 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;
        }
    }

    if (n == k)
    {
        ans *= 2;
        ans %= mod;
    }

    cout << ans;

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base12/50
1Accepted0/03ms1976 KiB
2Wrong answer0/017ms4964 KiB
3Accepted1/13ms2172 KiB
4Accepted1/13ms2268 KiB
5Accepted1/13ms2448 KiB
6Accepted1/13ms2640 KiB
7Accepted1/13ms2864 KiB
8Wrong answer0/13ms2956 KiB
9Wrong answer0/13ms3084 KiB
10Wrong answer0/23ms3296 KiB
11Wrong answer0/23ms3520 KiB
12Wrong answer0/23ms3608 KiB
13Wrong answer0/23ms3628 KiB
14Accepted2/23ms3704 KiB
15Wrong answer0/23ms3544 KiB
16Wrong answer0/23ms3392 KiB
17Wrong answer0/23ms3520 KiB
18Wrong answer0/23ms3592 KiB
19Wrong answer0/23ms3596 KiB
20Wrong answer0/23ms3592 KiB
21Accepted1/13ms3596 KiB
22Wrong answer0/214ms6800 KiB
23Wrong answer0/214ms6780 KiB
24Wrong answer0/217ms6940 KiB
25Wrong answer0/218ms6876 KiB
26Accepted2/217ms6872 KiB
27Wrong answer0/210ms6924 KiB
28Wrong answer0/216ms6968 KiB
29Wrong answer0/214ms7176 KiB
30Wrong answer0/217ms7132 KiB
31Accepted2/217ms7136 KiB