| 24263 | 2026-02-07 16:26:20 | ercseferenc | Szitakötő (50 pont) | cpp17 | Forditási hiba |
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main()
{
ll mod=1e9+7;
int n,m; cin>>n>>m; m--;
if(n==3){
int x,y,z; f>>x>>y>>z;
if(m==1)cout<<0;
if(m==2)if(x+y>z)cout<<4;else cout<<0;
if(m==3)if(x+y<=z)cout<<8; else cout<<4;
return 0;}
vector<ll>s(n);
cin>>s[0];
for(int i=1; i<n; i++){
ll x; cin>>x;
s[i]=s[i-1]+x;}
ll t=s[m]-s[m-1];
int poz=m-1;
while(t<s[poz] && poz>=0){
t+=s[poz]-s[poz-1];
poz--;}
ll ans=1;
poz++;
for(int i=0; i<poz; i++)
ans=(ans*2)%mod;
vector<ll>dp(n);
dp[m-1]=0;
dp[m]=ans;
bool leh=1;
for(int i=m+1; i<n; i++){
int x=m+1,y=i;
if(2*s[i-1]<s[i])leh=0;
while(leh && x!=y){
int k=(x+y)/2;
if(2*s[k-1]>s[i])y=k;
else x=k+1;}
dp[i]=(2*dp[i-1]-dp[x-2])%mod;
if(dp[i]<0)dp[i]+=mod;}
if(leh){
dp[n-1]-=dp[n-2];
dp[n-1]=(dp[n-1]*2)%mod;
if(dp[n-1]<0)dp[n-1]+=mod;
cout<<dp[n-1];}
else cout<<0;
return 0;
}open /var/local/lib/isolate/420/box/a.out: no such file or directory
main.cpp: In function 'int main()':
main.cpp:9:20: error: 'f' was not declared in this scope
9 | int x,y,z; f>>x>>y>>z;
| ^