QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#24196 | #862. Social Justice | DoorKickers | WA | 0ms | 3612kb | C++20 | 2.0kb | 2022-03-27 18:54:39 | 2022-04-30 05:15:08 |
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;
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++;
}
mx = max(mx, r - i);
sum -= a[i].first;
}
// cout << "mx = " << mx << '\n';
sum = 0;
for (int i = 2; i <= mx; i++) {
sum += a[i].first;
}
vector<int> ans;
vector<int> vis(n + 2);
for (int i = mx; i <= n; i++) {
int l = 1;
int r = i - mx + 1;
while (l < r) {
int mid = (l + r) >> 1;
if (a[i].first * q * mx <= (sum + a[mid].first) * p) {
r = mid;
}
else {
l = mid + 1;
}
}
if (a[i].first * q * mx <= (sum + a[l].first) * p) {
vis[l]++;
vis[i + 1]--;
}
if (i == n) break;
sum -= a[i - mx + 2].first;
sum += a[i + 1].first;
}
int fl = 0;
for (int i = 1; i <= n; i++) {
fl += vis[i];
if (fl == 0) {
ans.push_back(a[i].second);
}
}
sort(ans.begin(), ans.end());
cout << ans.size() << '\n';
for (int i = 0; i < ans.size(); i++) {
cout << ans[i] << ' ';
}
cout << '\n';
}
return 0;
}
/*
1
6
1 2 3 4 1000 10000
4 3
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3548kb
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: 0ms
memory: 3612kb
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 1 5 6 2 1 5 3 2 4 6 6 2 4 6 12 14 16 8 2 4 6 12 14 16 22 24 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 0 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 2 9 12 20 1 2 3 4 5 6 7 8 9 10 11 12 1...
result:
wrong answer 38th numbers differ - expected: '13', found: '20'