222342026-01-14 18:20:55algoproBájital (80 pont)cpp17Wrong answer 16/80300ms1372 KiB
// UUID: f9946e32-69fe-4631-a0ec-2086a175dd06
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
//#define int long long
//#define INT_MIN LLONG_MIN
//#define INT_MAX LLONG_MAX

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
	int n,x,vsum=0;
    cin >> n >> x;
    vector<long long> v(n);
    for (int i=0; i<n; i++) {
        cin >> v[i];
        vsum += v[i];
    }
    sort(v.begin(),v.end());
    int first=0, last=n-1;
    int count = 0;
    while (first<=last&&1<=v[first]&&x<=v[last]&&vsum>=(x+1)) {
        v[first]-=1;
        if (v[first]<=0) first++;
        v[last]-=x;
        if (v[last]-x<=0) last--;
        count++;
        
    }
    cout << count;
}
SubtaskSumTestVerdictTimeMemory
base16/80
1Accepted0/01ms316 KiB
2Wrong answer0/02ms316 KiB
3Wrong answer0/294ms332 KiB
4Wrong answer0/279ms316 KiB
5Wrong answer0/214ms316 KiB
6Wrong answer0/294ms432 KiB
7Wrong answer0/4187ms316 KiB
8Time limit exceeded0/4284ms512 KiB
9Wrong answer0/220ms1080 KiB
10Time limit exceeded0/2300ms1372 KiB
11Time limit exceeded0/2300ms1076 KiB
12Time limit exceeded0/2273ms1076 KiB
13Wrong answer0/220ms1076 KiB
14Wrong answer0/220ms1076 KiB
15Wrong answer0/221ms1076 KiB
16Wrong answer0/220ms1076 KiB
17Wrong answer0/220ms1076 KiB
18Wrong answer0/220ms1076 KiB
19Wrong answer0/220ms1260 KiB
20Wrong answer0/220ms1076 KiB
21Wrong answer0/220ms1096 KiB
22Wrong answer0/220ms1084 KiB
23Accepted4/41ms316 KiB
24Accepted4/41ms320 KiB
25Accepted4/41ms316 KiB
26Accepted4/414ms1076 KiB
27Wrong answer0/420ms1088 KiB
28Wrong answer0/420ms1272 KiB
29Wrong answer0/420ms1072 KiB
30Wrong answer0/220ms1088 KiB
31Wrong answer0/221ms1088 KiB
32Time limit exceeded0/2282ms1260 KiB
33Time limit exceeded0/2282ms1268 KiB