QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#24185 | #862. Social Justice | DoorKickers | WA | 27ms | 3696kb | C++20 | 1.5kb | 2022-03-27 18:16:52 | 2022-04-30 05:14:38 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
int tt; cin >> tt;
while (tt--) {
int n; cin >> n;
vector<pair<int, int>> a(n + 1);
for (int i = 1; i <= n; i++) {
cin >> a[i].first;
a[i].second = i;
}
int p, q; cin >> p >> q;
int r = 1;
int sum = 0;
int mx = 0;
int pos = 0;
sort(a.begin() + 1, a.begin() + 1 + n);
for (int i = 1; i <= n; i++) {
r = max(r, i + 1);
sum += a[i].first;
while (r <= n && a[r].first * q * (r - i + 1) <= (a[r].first + sum) * p) {
sum += a[r].first;
r++;
}
if (r - i > mx) {
mx = r - i;
pos = r;
}
sum -= a[i].first;
}
sum = 0;
for (int i = 1; i <= mx; i++) {
sum += a[i].first;
}
vector<int> ans;
for (int i = mx; i <= n; i++) {
if (a[i].first * q * mx > sum * p) {
ans.push_back(a[i].second);
}
sum -= a[i - mx + 1].first;
sum += a[i + 1].first;
}
cout << ans.size() << '\n';
for (int i = 0; i < ans.size(); i++) {
cout << ans[i] << ' ';
}
cout << '\n';
}
return 0;
}
/*
3
4
1 2 3 4
3 2
5
1 15 2 5 1
2 1
5
1 2 3 1000 10000
4 3
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3628kb
input:
3 4 1 2 3 4 3 2 5 1 15 2 5 1 2 1 5 1 2 3 1000 10000 4 3
output:
0 1 2 2 4 5
result:
ok 6 numbers
Test #2:
score: -100
Wrong Answer
time: 27ms
memory: 3696kb
input:
1000 1 10 3 2 2 10 100 3 2 3 10 10 100 3 2 4 1 2 3 4 3 2 5 1 15 2 5 1 2 1 5 1 2 3 1000 10000 4 3 6 1 2 3 4 1000 10000 4 3 5 50000 2 1 1 5000 2 1 10 1 15 2 5 1 10000 1 1 1 1 2 1 20 1 15 2 5 1 10000 1 1 1 1 1 15 2 5 1 10000 1 1 1 1 2 1 25 1 15 2 5 1 10000 1 1 1 1 1 15 2 5 1 10000 1 1 1 1 1 15 2 5 1 2 ...
output:
0 0 1 3 0 1 2 2 4 5 3 3 5 6 2 5 1 3 4 2 6 6 4 14 2 12 6 16 8 4 14 24 2 12 22 6 16 15 6 7 8 9 10 11 12 20 19 18 17 16 15 14 13 10 11 12 20 19 18 17 16 15 14 13 0 11 2 8 1 6 10 11 13 14 15 19 20 10 17 9 1 3 8 10 13 14 15 18 11 2 14 4 6 8 11 15 16 18 19 20 10 20 2 3 8 9 10 11 12 16 17 ...
result:
wrong answer 12th numbers differ - expected: '1', found: '3'