QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#554465#8777. Passport StampsluqyouWA 5ms5240kbC++14810b2024-09-09 11:24:112024-09-09 11:24:14

Judging History

This is the latest submission verdict.

  • [2024-09-09 11:24:14]
  • Judged
  • Verdict: WA
  • Time: 5ms
  • Memory: 5240kb
  • [2024-09-09 11:24:11]
  • Submitted

answer

#include<bits/stdc++.h>
#define int long long
#define i128 __int128
using namespace std;
#define fi first
#define sc second
#define pii pair<int,int>
#define pb push_back
const int maxn=1e5+10;
int n,num;
i128 p,a[maxn];
bool chk(int x){
	i128 now=a[x]-1;
	for(int i=1;i<x;i++) now+=a[i],now+=a[x]-1;
	return (p-now>=a[x]);
}
void solve(){
	cin>>n>>num,p=num;
	for(int i=1;i<=n;i++) cin>>num,a[i]=num;
	int l=1,r=n,mid=0;
	while(l<=r) mid=(l+r)>>1,(chk(mid)?l=mid+1:r=mid-1);
	cout<<l-1<<endl;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    int t=1;
//    cin>>t;
    while(t--) solve();
    return 0;
}
/*
Samples
input:

output:

THINGS TODO:
检查freopen,尤其是后缀名
检查空间
检查调试语句是否全部注释
*/

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3628kb

input:

5 15
1
2
3
4
5

output:

3

result:

ok single line: '3'

Test #2:

score: 0
Accepted
time: 4ms
memory: 5240kb

input:

100000 559309580160692839
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

output:

84437

result:

ok single line: '84437'

Test #3:

score: -100
Wrong Answer
time: 5ms
memory: 5192kb

input:

100000 890934113082207108
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

output:

100000

result:

wrong answer 1st lines differ - expected: '53636', found: '100000'