QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#323271 | #7627. Phony | BrotherCall | WA | 1ms | 5764kb | C++14 | 1.6kb | 2024-02-09 04:01:12 | 2024-02-09 04:01:12 |
Judging History
answer
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#define int long long
using namespace std;
const int N = 1e6 + 100;
int n , m , k;
int a[N] , b[N] , c[N];
vector<int> v;
bool compare(int s1 ,int s2) {
return s1 > s2;
}
signed main() {
cin >> n >> m >> k;
for(int i = 1;i <= n;i ++)
cin >> a[i];
sort(a + 1 , a + 1 + n , compare);
for(int i = 1;i < n;i ++) {
int del = a[i] / k - a[i + 1] / k;
b[i] = b[i - 1] + i * del;
c[i] = a[i] / k * k;
}
c[n] = a[n] / k * k;
int cnt = 0 , hand = 1 , lst;
v.push_back(a[1] % k);
while(cnt >= b[hand] && hand < n) {
auto it = upper_bound(v.begin() , v.end() , a[hand + 1] % k);
v.insert(it , a[hand + 1] % k);
hand ++;
}
for(int i = 1;i <= m;i ++) {
char ch;int x;
cin >> ch >> x;
if(ch == 'A') {
if(x <= hand) {
int nb = cnt - b[hand - 1];
int st = c[hand] - nb / hand * k;
int kk = nb % hand;
//cout << "fk " << kk <<' '<<nb<< endl;
if(x + kk <= hand) {
int now = (kk + x) % hand;
if(now == 0) now = hand;
int nxt = v[hand - now];
cout << ((st + nxt == 6103)?6114:(st + nxt)) << endl;
}
else {
int now = (kk + x) % hand;
if(now == 0) now = hand;
int nxt = v[hand - now];
cout << ((st + nxt - k == 6103)?6114:(st + nxt - k)) << endl;
}
} else {
cout << a[x] << endl;
}
} else {
cnt += x;
while(cnt >= b[hand] && hand < n) {
auto it = upper_bound(v.begin() , v.end() , a[hand + 1] % k);
v.insert(it , a[hand + 1] % k);
hand ++;
}
}
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 5620kb
input:
3 5 5 7 3 9 A 3 C 1 A 2 C 2 A 3
output:
3 4 -1
result:
ok 3 lines
Test #2:
score: 0
Accepted
time: 1ms
memory: 5644kb
input:
5 8 8 294 928 293 392 719 A 4 C 200 A 5 C 10 A 2 C 120 A 1 A 3
output:
294 200 191 0 -2
result:
ok 5 lines
Test #3:
score: 0
Accepted
time: 1ms
memory: 5764kb
input:
100 100 233 5101 8001 6561 6329 6305 7745 4321 811 49 1121 3953 8054 8415 9876 6701 4097 6817 6081 495 5521 2389 2042 4721 8119 7441 7840 8001 5756 5561 129 1 5981 4801 7201 8465 7251 6945 5201 5626 3361 5741 3650 7901 2513 8637 3841 5621 9377 101 3661 5105 4241 5137 7501 5561 3581 4901 561 8721 811...
output:
6881 9161 4721 8200 2945 7647 7531 5291 5001 2042 4721 4721 6881 4097 7187 7218 7035 7018 811 6752 2561 6683 6114 6135 3581 5291 1485 5957 5393 2042 5303 5171 5205 4721 5084 4029 4097 4591 4816 4586 4705 2042 4535 4454 4603 4435 3581 4345 115 2042 4284 2042 4274 1485 4326 -17552
result:
ok 56 lines
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 5648kb
input:
100 300 3453213 4777243 17293302 43453992 45342348 82151965 11360220 63630258 38237802 1 56066162 75020027 83365329 100659838 2141897 73421986 102600372 100824166 46869742 31931613 26168082 41399743 62249685 31666167 96044265 81576202 44039394 94271661 37319513 46613514 14176026 23991180 3310773 635...
output:
16238806 100824166 74028301 100824166 98384591 100659838 3066866 82151965 78167694 86340309 16238806 64926204 73585978 16238806 64926204 4777243 62249685 78951605 16238806 3066866 77665313 78427881 75980670 43453992 16238806 1 78122989 62404688 73585978 3310773 35761909 44960459 73552383 72045179 16...
result:
wrong answer 5th lines differ - expected: '98702945', found: '98384591'