QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#554542 | #8777. Passport Stamps | chengning0909 | WA | 0ms | 3616kb | C++20 | 731b | 2024-09-09 11:55:07 | 2024-09-09 11:55:14 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e5 + 10;
const ll INF = 2e18;
int n, top;
ll p, a[N], stk[N];
__int128 sum;
int main() {
ios::sync_with_stdio(0), cin.tie(0);
cin >> n >> p;
for (int i = 1; i <= n; i++) cin >> a[i];
for (int i = 1; i <= n; i++) {
int pos = i;
while (top && a[stk[top]] > a[i]) {
sum -= a[stk[top]] * (pos - stk[top]);
pos = stk[top], top--;
}
sum += (i - stk[top]) * a[i], stk[++top] = i;
sum += a[i] - 1;
//cout << (ll)sum << '\n';
if (sum > p) {
cout << i; return 0;
}
}
cout << n;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3616kb
input:
5 15 1 2 3 4 5
output:
4
result:
wrong answer 1st lines differ - expected: '3', found: '4'