QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#453820#8777. Passport StampsMay_27thWA 0ms4336kbC++14954b2024-06-24 12:24:402024-06-24 12:24:41

Judging History

你现在查看的是最新测评结果

  • [2024-06-24 12:24:41]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:4336kb
  • [2024-06-24 12:24:40]
  • 提交

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<int> 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 << check(4) << "\n";
  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: 3836kb

input:

5 15
1
2
3
4
5

output:

3

result:

ok single line: '3'

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 4336kb

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:

0

result:

wrong answer 1st lines differ - expected: '84437', found: '0'