QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#451273 | #8777. Passport Stamps | henryx# | WA | 4ms | 3780kb | C++20 | 596b | 2024-06-23 02:08:46 | 2024-06-23 02:08:46 |
Judging History
answer
#include <bits/stdc++.h>
const char nl = '\n';
using namespace std;
using ll = long long;
using ld = long double;
int main() {
cin.tie(0)->sync_with_stdio(0);
int n; ll p; cin >> n >> p;
vector<ll> c(n);
for (ll& i : c) cin >> i;
int l = 0, r = n-1, ans = 0;
while (l <= r) {
int x = (l+r)/2;
ll gap = c[x]-1;
ll rem = p;
for (int i = 0; i < x; i++) {
rem -= c[i] + gap;
}
if (rem < gap+1) {
r = x-1;
} else {
ans = x+1;
l = x+1;
}
}
cout << ans << nl;
}
// ...............
// ...x...xx...xxx
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3752kb
input:
5 15 1 2 3 4 5
output:
3
result:
ok single line: '3'
Test #2:
score: 0
Accepted
time: 4ms
memory: 3780kb
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: 4ms
memory: 3752kb
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'