# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
39703 | 2018-01-17T12:16:09 Z | Pajaraja | 중앙값 배열 (balkan11_medians) | C++14 | 69 ms | 7872 KB |
#include <bits/stdc++.h> using namespace std; bool u[200007],k[200007]; int b[100007],add; vector<int> ub[100007]; int main() { int n; scanf("%d",&n); for(int i=0;i<n;i++) scanf("%d",&b[i]); priority_queue<int> g,l; //for(int i=0;i<n-1;i++) for(int j=fmin(b[i],b[i+1]);j<fmax(b[i],b[i+1]);j++) k[j]=true; for(int i=1;i<2*n;i++) if(!k[i]) { g.push(i); l.push(-i); } u[b[0]]=true; add=1; printf("%d ",b[0]); for(int i=0;i<n-1;i++) { if(!u[b[i+1]]) { u[b[i+1]]=true; add++; printf("%d ",b[i+1]); } if(b[i]>b[i+1]) { while(add<2*i+3) { int c=-l.top(); l.pop(); if(u[c]) continue; u[c]=true; add++; printf("%d ",c); } } if(b[i]==b[i+1]) { while(add<2*i+2) { int c=-l.top(); l.pop(); if(u[c]) continue; u[c]=true; add++; printf("%d ",c); } while(add<2*i+3) { int c=g.top(); g.pop(); if(u[c]) continue; u[c]=true; add++; printf("%d ",c); } } if(b[i]<b[i+1]) { while(add<2*i+3) { int c=g.top(); g.pop(); if(u[c]) continue; u[c]=true; add++; printf("%d ",c); } } /*for(int j=fmin(b[i],b[i+1]);j<fmax(b[i],b[i+1]);j++) { g.push(j); l.push(-j); }*/ } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 5140 KB | Output is correct |
2 | Correct | 0 ms | 5140 KB | Output is correct |
3 | Correct | 0 ms | 5140 KB | Output is correct |
4 | Correct | 0 ms | 5140 KB | Output is correct |
5 | Correct | 0 ms | 5140 KB | Output is correct |
6 | Correct | 0 ms | 5140 KB | Output is correct |
7 | Correct | 0 ms | 5140 KB | Output is correct |
8 | Correct | 0 ms | 5140 KB | Output is correct |
9 | Correct | 0 ms | 5140 KB | Output is correct |
10 | Correct | 0 ms | 5140 KB | Output is correct |
11 | Correct | 0 ms | 5140 KB | Output is correct |
12 | Correct | 0 ms | 5140 KB | Output is correct |
13 | Correct | 0 ms | 5140 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 5140 KB | Output is correct |
2 | Correct | 0 ms | 5300 KB | Output is correct |
3 | Correct | 6 ms | 5300 KB | Output is correct |
4 | Correct | 6 ms | 5432 KB | Output is correct |
5 | Correct | 13 ms | 5820 KB | Output is correct |
6 | Correct | 29 ms | 6592 KB | Output is correct |
7 | Correct | 69 ms | 7872 KB | Output is correct |