QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#451273#8777. Passport Stampshenryx#WA 4ms3780kbC++20596b2024-06-23 02:08:462024-06-23 02:08:46

Judging History

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

  • [2024-06-23 02:08:46]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:3780kb
  • [2024-06-23 02:08:46]
  • 提交

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

Details

Tip: Click on the bar to expand more detailed information

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'