252072026-02-18 13:06:23sscrazyyBájital (80 pont)cpp17Wrong answer 8/80300ms1272 KiB
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int n, x;
    cin >> n >> x;
    
    vector<long long> a(n);
    long long total = 0;
    
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        total += a[i];
    }
    
    // Each potion needs 1 + x liters
    // Maximum possible
    long long max_potions = total / (1 + x);
    
    // Verify we can actually make this many
    sort(a.begin(), a.end(), greater<long long>());
    
    long long potions = 0;
    long long remaining = total;
    
    for (int i = 0; i < n && remaining >= 1 + x; i++) {
        long long can_boil = a[i];
        long long need_add = remaining - a[i];
        
        while (can_boil >= 1 && need_add >= x && remaining >= 1 + x) {
            potions++;
            can_boil--;
            need_add -= x;
            remaining -= (1 + x);
        }
    }
    
    cout << min(potions, max_potions) << endl;
    
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base8/80
1Wrong answer0/01ms316 KiB
2Accepted0/01ms504 KiB
3Wrong answer0/217ms316 KiB
4Wrong answer0/214ms316 KiB
5Wrong answer0/23ms316 KiB
6Wrong answer0/217ms404 KiB
7Wrong answer0/432ms412 KiB
8Wrong answer0/4123ms416 KiB
9Time limit exceeded0/2300ms1076 KiB
10Time limit exceeded0/2300ms1076 KiB
11Time limit exceeded0/2282ms1076 KiB
12Time limit exceeded0/2284ms1076 KiB
13Time limit exceeded0/2287ms1076 KiB
14Time limit exceeded0/2300ms1076 KiB
15Time limit exceeded0/2300ms1076 KiB
16Time limit exceeded0/2279ms1268 KiB
17Time limit exceeded0/2280ms1076 KiB
18Time limit exceeded0/2300ms1076 KiB
19Time limit exceeded0/2300ms1076 KiB
20Time limit exceeded0/2279ms1076 KiB
21Time limit exceeded0/2282ms1076 KiB
22Time limit exceeded0/2300ms1076 KiB
23Wrong answer0/41ms316 KiB
24Wrong answer0/41ms508 KiB
25Wrong answer0/41ms384 KiB
26Wrong answer0/426ms1196 KiB
27Time limit exceeded0/4300ms1076 KiB
28Accepted4/4142ms1192 KiB
29Accepted4/493ms1272 KiB
30Wrong answer0/270ms1192 KiB
31Wrong answer0/250ms1196 KiB
32Time limit exceeded0/2277ms1076 KiB
33Time limit exceeded0/2300ms1268 KiB