QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#437596#8777. Passport Stampsucup-team045#WA 5ms3852kbC++20879b2024-06-09 13:49:072024-06-09 13:49:08

Judging History

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

  • [2024-06-09 13:49:08]
  • 评测
  • 测评结果:WA
  • 用时:5ms
  • 内存:3852kb
  • [2024-06-09 13:49:07]
  • 提交

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

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

}

详细

Test #1:

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

input:

5 15
1
2
3
4
5

output:

3

result:

ok single line: '3'

Test #2:

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

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'