QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#437603 | #8777. Passport Stamps | ucup-team045# | WA | 2ms | 4000kb | C++20 | 877b | 2024-06-09 13:55:15 | 2024-06-09 13:55:15 |
Judging History
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 sum = 0;
for(int i = 0; i + 1 < mid; i++){
sum += a[i];
if (sum > m) return false;
}
LL mx = (m - sum + mid - 1) / mid;
return mx >= a[mid - 1];
};
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: 1ms
memory: 3588kb
input:
5 15 1 2 3 4 5
output:
3
result:
ok single line: '3'
Test #2:
score: -100
Wrong Answer
time: 2ms
memory: 4000kb
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'