QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#453823 | #8777. Passport Stamps | May_27th | WA | 9ms | 4572kb | C++14 | 922b | 2024-06-24 12:26:40 | 2024-06-24 12:26:41 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define i64 long long
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
int N; i64 P, a[100005];
bool check(int l) {
priority_queue<i64> pq;
pq.push(P);
for (int i = 1; i <= l; i ++) {
i64 cur = pq.top(); pq.pop();
if (cur < a[i]) return true;
i64 left = min(cur - a[i], a[l] - 1);
if (left) pq.push(left);
i64 right = cur - a[i] - left;
if (right) pq.push(right);
}
return false;
}
void Solve(void) {
cin >> N >> P;
for (int i = 1; i <= N; i ++) cin >> a[i];
int l = 1, h = N;
while (l <= h) {
int mid = (l + h)/2;
// nearest can't go
if (check(mid)) h = mid - 1;
else l = mid + 1;
}
cout << l - 1 << "\n";
}
signed main() {
ios_base::sync_with_stdio(false); cin.tie(0);
int Tests = 1; // cin >> Tests;
while (Tests --) {
Solve();
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3632kb
input:
5 15 1 2 3 4 5
output:
3
result:
ok single line: '3'
Test #2:
score: 0
Accepted
time: 5ms
memory: 4348kb
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: 9ms
memory: 4572kb
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'