QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#554405#8777. Passport Stampschengning0909WA 4ms5196kbC++14611b2024-09-09 11:04:352024-09-09 11:04:44

Judging History

This is the latest submission verdict.

  • [2024-09-09 11:04:44]
  • Judged
  • Verdict: WA
  • Time: 4ms
  • Memory: 5196kb
  • [2024-09-09 11:04:35]
  • Submitted

answer

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const int N = 1e5 + 10;
const ll INF = 2e18;

int n;
ll p, a[N], mmin[N];
__int128 tp;

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    cin >> n >> p;
    for (int i = 1; i <= n; i++) cin >> a[i];
    mmin[n + 1] = INF;
    for (int i = n; i >= 1; i--) mmin[i] = min(mmin[i + 1], a[i]);
    mmin[n + 1] = 0;

    for (int i = 1; i <= n; i++) {
        if (tp + mmin[i + 1] > p) {
            cout << i - 1; return 0;
        }
        tp += mmin[i + 1] + a[i] - 1;
    }
    cout << n;
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3556kb

input:

5 15
1
2
3
4
5

output:

3

result:

ok single line: '3'

Test #2:

score: -100
Wrong Answer
time: 4ms
memory: 5196kb

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:

84438

result:

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