QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#589861#8777. Passport Stampspikaka#WA 8ms5732kbC++17852b2024-09-25 20:23:552024-09-25 20:23:56

Judging History

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

  • [2024-09-25 20:23:56]
  • 评测
  • 测评结果:WA
  • 用时:8ms
  • 内存:5732kb
  • [2024-09-25 20:23:55]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
using namespace std;
void solve(){
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<int> suf(n);
    suf[n - 1] = a[n - 1];
    for (int i = n - 2; i >= 0; i--) {
        suf[i] = min(suf[i + 1], a[i + 1]);
    }
    int ans = 0;
    priority_queue<int> q;
    q.push(m);
    for (int i = 0; i < n; i++) {
        if (q.empty() || q.top() < a[i]) {
            break;
        }
        int cur = q.top();
        q.pop();
        ans++;
        cur -= a[i];
        q.push(suf[i] - 1);
        q.push(cur - suf[i] + 1);
    }
    cout << ans << endl;
}
signed main(){
    ios::sync_with_stdio(false); 
    cin.tie(0);
    int t = 1;
    while (t--) {
       solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5 15
1
2
3
4
5

output:

3

result:

ok single line: '3'

Test #2:

score: 0
Accepted
time: 7ms
memory: 5732kb

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: 8ms
memory: 5712kb

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'