QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#509544 | #5719. Perfect Flush | exxqfu | WA | 24ms | 5764kb | C++14 | 1.1kb | 2024-08-08 15:55:32 | 2024-08-08 15:55:36 |
Judging History
answer
#include <cstdio>
#include <queue>
#include <utility>
#define rep(i, d, u) for(int i = d; i <= u; ++i)
int ured() {
int ch, re = 0;
do {
ch = getchar();
} while(ch < '0' || '9' < ch);
do {
re = re * 10 + (ch ^ '0');
} while('0' <= (ch = getchar()) && ch <= '9');
return re;
}
void uwit(int da) {
int ch[21], cn = 0;
do {
ch[++cn] = da % 10;
} while(da /= 10);
do {
putchar('0' ^ ch[cn]);
} while(--cn);
}
const int _maxn = 200011;
int n, m, x[_maxn], lasp[_maxn], rans[_maxn], tpos;
std :: priority_queue<std :: pair<int, int>> lasq;
std :: priority_queue<int> datq;
bool firp[_maxn], used[_maxn];
int main() {
n = ured(), m = ured();
rep(i, 1, n) {
x[i] = ured();
if(!lasp[x[i]]) {
firp[i] = 1;
}
lasp[x[i]] = i;
}
rep(i, 1, m) {
lasq . push(std :: make_pair(-lasp[i], i));
}
rep(i, 1, m) {
while(used[lasq . top() . second]) {
lasq . pop();
}
while(tpos < -lasq . top() . first) {
if(firp[++tpos]) {
datq . push(-x[tpos]);
}
}
used[rans[i] = -datq . top()] = 1, datq . pop();
}
rep(i, 1, m) {
uwit(rans[i]), putchar(i == m ? '\n' : ' ');
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3632kb
input:
6 3 3 2 1 3 1 3
output:
2 1 3
result:
ok single line: '2 1 3'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3652kb
input:
10 5 5 4 3 2 1 4 1 1 5 5
output:
3 2 1 4 5
result:
ok single line: '3 2 1 4 5'
Test #3:
score: -100
Wrong Answer
time: 24ms
memory: 5764kb
input:
200000 100000 29798 79235 44935 20368 15319 34973 11273 40142 82579 68354 79772 77697 59566 18516 50787 76175 25710 47305 87751 59942 49064 26470 38196 44038 38745 39903 71503 18468 59632 23169 10201 26065 62767 44170 37027 69281 7161 62056 7829 13359 80329 68362 59458 6406 80936 96142 56500 57523 1...
output:
29798 11273 15319 20368 34973 40142 44935 68354 79235 79772 18516 25710 47305 50787 59566 59942 26470 38196 38745 39903 44038 49064 71503 10201 18468 23169 26065 59632 62767 44170 7161 37027 62056 7829 13359 68362 6406 56500 57523 6629 15180 21853 21246 28937 52201 56121 2741 15698 29933 38329 59458...
result:
wrong answer 1st lines differ - expected: '29798 11273 40142 68354 79772 ...6 42906 92073 84291 44638 91402', found: '29798 11273 15319 20368 34973 ...84 94031 1850 26416 77126 91402'