QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#437590#8777. Passport Stampsucup-team045#WA 5ms3896kbC++20925b2024-06-09 13:45:362024-06-09 13:45:37

Judging History

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

  • [2024-06-09 13:45:37]
  • 评测
  • 测评结果:WA
  • 用时:5ms
  • 内存:3896kb
  • [2024-06-09 13:45:36]
  • 提交

answer

#include<iostream>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
using LL = long long;

int main(){

#ifdef LOCAL
    freopen("data.in", "r", stdin);
    freopen("data.out", "w", stdout);
#endif

    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(0);

    int n; LL m;
    cin >> n >> m;
    vector<LL> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    if (a[0] > m){
        cout << 0 << '\n';
        return 0;
    }

    auto check = [&](int mid){
        LL t = a[mid] - 1;
        LL last = 0;
        for(int i = 0; i < mid; i++){
            last += t + a[i];
            if (last >= m) return true;
        }
        return false;
    };

    int l = 0, r = n;
    while(l < r){
        int mid = (l + r) / 2;
        if (check(mid)) r = mid;
        else l = mid + 1;
    }
    cout << r << '\n';

}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3520kb

input:

5 15
1
2
3
4
5

output:

3

result:

ok single line: '3'

Test #2:

score: -100
Wrong Answer
time: 5ms
memory: 3896kb

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:

99999

result:

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