QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#24191#862. Social JusticeDoorKickersWA 18ms3708kbC++201.5kb2022-03-27 18:23:422022-04-30 05:14:55

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-04-30 05:14:55]
  • 评测
  • 测评结果:WA
  • 用时:18ms
  • 内存:3708kb
  • [2022-03-27 18:23:42]
  • 提交

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;
        }
        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);
            }
            if (i == n) break;
            sum -= a[i - mx + 1].first;
            sum += a[i + 1].first;
        }
        sort(ans.begin(), ans.end());
        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
*/

详细

Test #1:

score: 100
Accepted
time: 2ms
memory: 3688kb

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: 18ms
memory: 3708kb

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
1 5 
3
2 4 6 
6
2 4 6 12 14 16 
8
2 4 6 12 14 16 22 24 
15
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 
10
11 12 13 14 15 16 17 18 19 20 
0

11
1 2 6 8 10 11 13 14 15 19 20 
10
1 3 8 9 10 13 14 15 17 18 
11
2 4 6 8 11 14 15 16 18 19 20 
10
2 3 8 9 10 11 12 16 17 20 ...

result:

wrong answer 12th numbers differ - expected: '1', found: '3'