248852026-02-16 13:53:52szjSzitakötő (50 pont)cpp17Wrong answer 10/5024ms4460 KiB
#include <bits/stdc++.h>
#define ll long long
#define blugy %1000000007
ll lowkey = 1e9+7;
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n, k, i, mer, mar=0, sum=1, p1, p2, p;
    cin >> n >> k;
    k--;
    vector<ll> t(n), dp(n,0), cucc(n,0),s(n);
    cin >> t[0];
    s[0]=t[0];
    for(i=1; i<n; i++)
    {
        cin >> t[i];
        s[i]=s[i-1]+t[i];
    }
    for(i=0; i<k; i++)if(2*s[i]<=s[k])sum=(sum<<1)blugy;
    cucc[k]=sum;
    dp[k]=sum;
    for(i=k+1; i<n; i++)
    {
        p1=k+1;
        p2=i;
        while(p1!=p2)
        {
            p=(p1+p2)/2;
            if(2*s[p]>s[i])p2=p;
            else p1=p+1;
        }
        if(s[i-1]>t[i])dp[i]=cucc[i-1]-cucc[p1-2];
        if(dp[i]<0)dp[i]+=lowkey;
        dp[i]=dp[i]blugy;
        cucc[i]=cucc[i-1]+dp[i];
        if(cucc[i]<0)cucc[i]+=lowkey;
        cucc[i]=cucc[i]blugy;
    }
    cout << (2*dp[n-1])blugy;
}
SubtaskSumTestVerdictTimeMemory
base10/50
1Accepted0/01ms316 KiB
2Wrong answer0/023ms4296 KiB
3Wrong answer0/11ms316 KiB
4Accepted1/11ms316 KiB
5Accepted1/11ms316 KiB
6Accepted1/11ms348 KiB
7Accepted1/11ms316 KiB
8Wrong answer0/11ms564 KiB
9Wrong answer0/11ms316 KiB
10Wrong answer0/21ms316 KiB
11Wrong answer0/21ms424 KiB
12Wrong answer0/21ms316 KiB
13Wrong answer0/21ms336 KiB
14Accepted2/21ms316 KiB
15Wrong answer0/22ms316 KiB
16Wrong answer0/21ms500 KiB
17Wrong answer0/21ms316 KiB
18Wrong answer0/21ms316 KiB
19Wrong answer0/21ms316 KiB
20Wrong answer0/22ms500 KiB
21Wrong answer0/11ms316 KiB
22Wrong answer0/218ms3860 KiB
23Wrong answer0/220ms4200 KiB
24Wrong answer0/224ms4404 KiB
25Wrong answer0/219ms4448 KiB
26Accepted2/217ms4284 KiB
27Wrong answer0/214ms3600 KiB
28Wrong answer0/218ms3380 KiB
29Wrong answer0/217ms4088 KiB
30Wrong answer0/221ms4460 KiB
31Accepted2/217ms4356 KiB