| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1352104 | luvwinter | Stone Arranging 2 (JOI23_ho_t1) | C++17 | 99 ms | 18096 KiB |
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int , int>
#define FOR(i , l , r) for(int i = (l) ; i <= (r) ; i++)
#define FOD(i , r , l) for(int i = (r) ; i >= (l) ; i--)
#define fi first
#define se second
#define endl '\n'
#define faster ios_base :: sync_with_stdio(false); cin.tie(NULL);
const int N = 2e5 + 5;
int a[N];
int n;
multiset<pii> s;
map<int , int> pos;
int nxt[N];
void solve (void) {
cin >> n;
FOR(i , 1 , n) cin >> a[i];
FOD(i , n , 1) {
if(pos[a[i]] == 0) {
pos[a[i]] = i;
nxt[i] = i;
}
else{
nxt[i] = pos[a[i]];
pos[a[i]] = i;
}
}
int curr = a[1];
int last = 0;
FOR(i , 1 , n) {
//cout << last << " " << i << endl;
if(i > last) {
cout << a[i] << endl;
curr = a[i];
last = nxt[i];
}
else{
if(curr == a[i]) {
last = nxt[i];
}
cout << curr << endl;
}
}
}
main() {
faster;
solve();
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
