QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#247803 | #7627. Phony | ucup-team2303# | WA | 2ms | 10004kb | C++17 | 2.8kb | 2023-11-11 16:06:36 | 2023-11-11 16:06:37 |
Judging History
answer
// #pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#include <bits/stdc++.h>
using namespace std;
#define PB emplace_back
// #define int long long
#define ll long long
#define vi vector<int>
#define siz(a) ((int) ((a).size()))
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)
void print(vi n) {rep(i, 0, siz(n) - 1) cerr << n[i] << " \n"[i == siz(n) - 1];}
const int N = 5e5;
int a, b, c, rt;
struct pii {
int x, y;
bool operator<(const pii &o) const {return x < o.x || (x == o.x && y < o.y);}
} s[N + 5];
int ls[N + 5], rs[N + 5], rnd[N + 5], siz[N + 5], w[N + 5], id;
int New(int n) {
++id;
siz[id] = 1;
w[id] = n;
rnd[id] = rand();
return id;
}
void up(int n) {
siz[n] = siz[ls[n]] + siz[rs[n]] + 1;
}
// void spl(int n, int k, int &x, int &y) {
// if(!n) return x = y = 0, void();
// if(siz[n] <= k) x = n, spl(rs[n], k, rs[n], y), up(n);
// else y = n, spl(ls[n], k, x, ls[n]), up(n);
// }
void slt(int n, int k, int &x, int &y) {
if(!n) return x = y = 0, void();
if(w[n] <= k) x = n, slt(rs[n], k, rs[n], y), up(n);
else y = n, slt(ls[n], k, x, ls[n]), up(n);
}
int mer(int n, int m) {
if(!n || !m) return n + m;
if(rnd[n] < rnd[m]) return rs[n] = mer(rs[n], m), up(n), n;
else return ls[m] = mer(n, ls[m]), up(m), m;
}
void ins(int n) {
int x, y;
slt(rt, n, x, y);
rt = mer(mer(x, New(n)), y);
}
int ask(int n, int m) {
if(m == siz[ls[n]] + 1) return w[n];
if(m <= siz[ls[n]]) return ask(ls[n], m);
else return ask(rs[n], m - siz[ls[n]] - 1);
}
signed main() {
// freopen(".in", "r", stdin);
// freopen(".out", "w", stdout);
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
srand(time(0));
cin >> a >> b >> c;
int x;
char y;
rep(i, 1, a) cin >> x, s[i] = pii {x / c, x % c};
sort(s + 1, s + a + 1);
int now = 0, r = a - 1, R = s[a].x, sz = 1;
ins(s[a].y);
rep(i, 1, b) {
cin >> y >> x;
if(y == 'C') now += x;
else {
while(r && (R - s[r].x) * sz <= now) {
now -= (R - s[r].x) * sz;
ins(s[r].y);
R = s[r].x;
++sz;
--r;
}
if(x > sz) {
// cout << r - (x - sz) + 1 << "#@!@#@" << sz << endl;
cout << s[r - (x - sz) + 1].x * c + s[r - (x - sz) + 1].y << '\n';
continue;
}
int ans = s[r + 1].x - now / sz, z = sz - now % sz;
// cout << i << ' ' << r << ' ' << now << ' ' << z << "#@!#@!" << endl;
// cout << sz << ' ' << z << "#@!!#" << endl;
if(x <= z) cout << ask(rt, z - x + 1) + ans * c << '\n';
else cout << ask(rt, sz - (x - z) + 1) + (ans - 1) * c << '\n';
}
}
return cerr << endl << 1.0 * clock() / CLOCKS_PER_SEC << endl, 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 7948kb
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: 9992kb
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: -100
Wrong Answer
time: 2ms
memory: 10004kb
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 6103 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:
wrong answer 23rd lines differ - expected: '6114', found: '6103'