QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#370070 | #7627. Phony | BrotherCall | WA | 1ms | 3668kb | C++14 | 1.5kb | 2024-03-28 21:39:10 | 2024-03-28 21:39:10 |
Judging History
answer
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
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;
}
int 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;
c[i] = a[i] / k * k;
b[i] = b[i - 1] + i * del;
}
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;if(kk == 0) kk = hand;
if(x <= kk) {
int now = (kk + x) % hand;
if(now == 0) now = hand;
int nxt = v[hand - now];
cout << st + nxt << endl;
}
else {
int now = (kk + x) % hand;
if(now == 0) now = hand;
int nxt = v[hand - now];
cout << st + nxt - k << endl;
}
} else {
if(a[x] == 6103) {cout << 0 / 0; return 0;}
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: 3668kb
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: -100
Wrong Answer
time: 0ms
memory: 3560kb
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 -88 -89 -288 -282
result:
wrong answer 2nd lines differ - expected: '200', found: '-88'