QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#426017#7614. Boxesreal_sigma_team#WA 35ms3612kbC++20618b2024-05-30 20:20:452024-05-30 20:20:45

Judging History

This is the latest submission verdict.

  • [2024-05-30 20:20:45]
  • Judged
  • Verdict: WA
  • Time: 35ms
  • Memory: 3612kb
  • [2024-05-30 20:20:45]
  • Submitted

answer

#include <bits/stdc++.h>

using namespace std;

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int &i : a)
        cin >> i;
    sort(a.begin(), a.end());
    multiset<int> now;
    for (int i = 0; i < n; ++i) {
        int cur = 0;
        while (!now.empty() && *now.begin() + cur <= a[i] / 2) {
            cur += *now.begin();
            now.erase(now.begin());
        }
        now.insert(a[i]);
    }
    cout << now.size() << '\n';
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    int t;
    cin >> t;
    while (t--)
        solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4
5
1 2 1 1 8
3
1 1 1
6
1 1 1 4 1 2
3
8 4 2

output:

1
3
3
1

result:

ok 4 lines

Test #2:

score: 0
Accepted
time: 35ms
memory: 3612kb

input:

500000
1
137438953472
1
8589934592
1
2048
1
1048576
1
68719476736
1
524288
1
8192
1
536870912
1
16777216
1
549755813888
1
268435456
1
524288
1
8589934592
1
32768
1
32768
1
32
1
131072
1
2
1
524288
1
34359738368
1
8589934592
1
8192
1
68719476736
1
8589934592
1
524288
1
268435456
1
68719476736
1
26214...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 500000 lines

Test #3:

score: -100
Wrong Answer
time: 14ms
memory: 3612kb

input:

1299
360
131072 4294967296 67108864 4294967296 1 16384 16384 16384 268435456 67108864 268435456 2048 4294967296 16384 64 16384 68719476736 4 524288 134217728 131072 131072 134217728 134217728 67108864 64 16384 2147483648 1024 4 64 131072 67108864 131072 134217728 2048 131072 134217728 17179869184 67...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

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