-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqual3.1.cpp
More file actions
42 lines (38 loc) · 799 Bytes
/
qual3.1.cpp
File metadata and controls
42 lines (38 loc) · 799 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <stdio.h>
#include <iostream>
using namespace std;
int B[100001];
int add(int B[100001], int p,int n,int x){
int temp=0;
int count=0;
for(int b=x;b<=n;b++){
temp+=B[b];
if(temp<=p){
count++;
}
else{
return count;
}
}
return count;
}
int main(){
FILE *fp =fopen("3.1.txt","w");
freopen("3.sample.txt","r",stdin);
int t;
cin >> t;
for(int i=1;i<=t;i++){
long long result=0;
int n,p;
cin >> n;
cin >> p;
for(int a=1;a<=n;a++){
cin>>B[a];
}
for(int a=1;a<=n;a++){
result+=add(B,p,n,a);
}
printf("Case #%d: %llu\n",i,result);
fprintf(fp,"Case #%d: %llu\n",i,result);
}
}