QOJ.ac
QOJ
The 2nd Universal Cup Finals is coming! Check out our event page, schedule, and competition rules!
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#323272 | #7627. Phony | BrotherCall | WA | 1ms | 5792kb | C++14 | 1.7kb | 2024-02-09 04:06:57 | 2024-02-09 04:06:57 |
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 ++;
}
}
}
for(int i = 1;i < v.size();i ++)
if(v[i] > v[i - 1]) cout << "fk!";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 5792kb
input:
3 5 5 7 3 9 A 3 C 1 A 2 C 2 A 3
output:
3 4 -1 fk!fk!
result:
wrong output format Extra information in the output file