QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#554473#8777. Passport Stampschengning0909WA 5ms4468kbC++14654b2024-09-09 11:27:062024-09-09 11:27:06

Judging History

This is the latest submission verdict.

  • [2024-09-09 11:27:06]
  • Judged
  • Verdict: WA
  • Time: 5ms
  • Memory: 4468kb
  • [2024-09-09 11:27:06]
  • 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];

bool Check(int x) {
    ll mmin = a[x + 1];
    __int128 tp = 0;
    for (int i = x; i >= 1; i--) {
        mmin = min(mmin, a[i]);
        tp += mmin + a[i] - 1;
    }
    return tp + 2 * a[x + 1] - 1 >= p;
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    cin >> n >> p;
    for (int i = 1; i <= n; i++) cin >> a[i];
    int l = 1, r = n;
    while (l < r) {
        int mid = (l + r) >> 1;
        Check(mid) ? r = mid : l = mid + 1;
    }
    cout << l;
    return 0;
}

详细

Test #1:

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

input:

5 15
1
2
3
4
5

output:

3

result:

ok single line: '3'

Test #2:

score: 0
Accepted
time: 4ms
memory: 4468kb

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: 5ms
memory: 4336kb

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'