Submission #48312397
Source Code Expand
Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include<bits/stdc++.h>
#define mz 998244353
using namespace std;
int a[250005];
long long sum[250005];
long long dp[250005],dps[250005];
int main(){
int n;
int l,r,mid,p1=0,p2=0;
long long s,ans=0;
scanf("%d%lld",&n,&s);
for(int i=1;i<=n;i++){
scanf("%d",&a[i]);
sum[i]=sum[i-1]+a[i];
}
a[n+1]=s+5;
sum[n+1]=sum[n]+a[n+1];
for(int i=1;i<=n;i++){
dp[i]=1;
if(sum[i]>s){
while(sum[i]-sum[p2]>s)
p2++;
while(sum[i-1]-sum[p1]>s)
p1++;
dp[i]+=dps[p2]-dps[p1];
}
ans+=dp[i]*(n-i+1);
dps[i]=dps[i-1]+dp[i];
//cout<<i<<" "<<dp[i]<<endl;
}
printf("%lld\n",ans);
return 0;
}
/*
0 1 2 3 4 5
0 1 1 1 1 1 1
1 0 1 2 3 4 5
2 0 1 3 6 10 15
3 0 1 4 10 20
4 0 1 5 15 35
d k
C(d+10^100-1,10^100-1)
C(a,b)=a!/(b!*(a-b)!)
=(d+10^100-1)!/((10^100-1)!*d!)
*/
Submission Info
Compile Error
Main.cpp: In function ‘int main()’:
Main.cpp:12:13: warning: unused variable ‘l’ [-Wunused-variable]
12 | int l,r,mid,p1=0,p2=0;
| ^
Main.cpp:12:15: warning: unused variable ‘r’ [-Wunused-variable]
12 | int l,r,mid,p1=0,p2=0;
| ^
Main.cpp:12:17: warning: unused variable ‘mid’ [-Wunused-variable]
12 | int l,r,mid,p1=0,p2=0;
| ^~~
Main.cpp:14:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
14 | scanf("%d%lld",&n,&s);
| ~~~~~^~~~~~~~~~~~~~~~
Main.cpp:16:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
16 | scanf("%d",&a[i]);
| ~~~~~^~~~~~~~~~~~
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
500 / 500 |
Status |
|
|
Set Name |
Test Cases |
Sample |
00-sample-001.txt, 00-sample-002.txt, 00-sample-003.txt, 00-sample-004.txt |
All |
00-sample-001.txt, 00-sample-002.txt, 00-sample-003.txt, 00-sample-004.txt, 01-001.txt, 01-002.txt, 01-003.txt, 01-004.txt, 01-005.txt, 01-006.txt, 01-007.txt, 01-008.txt, 01-009.txt, 01-010.txt, 01-011.txt, 01-012.txt, 01-013.txt, 01-014.txt, 01-015.txt, 01-016.txt, 01-017.txt, 01-018.txt, 01-019.txt, 01-020.txt, 01-021.txt, 01-022.txt, 01-023.txt, 01-024.txt, 01-025.txt |
Case Name |
Status |
Exec Time |
Memory |
00-sample-001.txt |
AC |
1 ms |
3768 KB |
00-sample-002.txt |
AC |
1 ms |
3696 KB |
00-sample-003.txt |
AC |
1 ms |
3636 KB |
00-sample-004.txt |
AC |
1 ms |
3824 KB |
01-001.txt |
AC |
1 ms |
3772 KB |
01-002.txt |
AC |
1 ms |
3828 KB |
01-003.txt |
AC |
1 ms |
3668 KB |
01-004.txt |
AC |
1 ms |
3672 KB |
01-005.txt |
AC |
1 ms |
3900 KB |
01-006.txt |
AC |
9 ms |
5480 KB |
01-007.txt |
AC |
26 ms |
9480 KB |
01-008.txt |
AC |
17 ms |
7288 KB |
01-009.txt |
AC |
14 ms |
6780 KB |
01-010.txt |
AC |
30 ms |
10412 KB |
01-011.txt |
AC |
31 ms |
10712 KB |
01-012.txt |
AC |
31 ms |
10452 KB |
01-013.txt |
AC |
30 ms |
10464 KB |
01-014.txt |
AC |
29 ms |
10708 KB |
01-015.txt |
AC |
30 ms |
10444 KB |
01-016.txt |
AC |
31 ms |
10540 KB |
01-017.txt |
AC |
29 ms |
10416 KB |
01-018.txt |
AC |
29 ms |
10416 KB |
01-019.txt |
AC |
30 ms |
10652 KB |
01-020.txt |
AC |
30 ms |
10608 KB |
01-021.txt |
AC |
29 ms |
10708 KB |
01-022.txt |
AC |
29 ms |
10488 KB |
01-023.txt |
AC |
30 ms |
10648 KB |
01-024.txt |
AC |
30 ms |
10460 KB |
01-025.txt |
AC |
28 ms |
10524 KB |