# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
103039 | 2019-03-28T20:27:58 Z | rzbt | medians (balkan11_medians) | C++14 | 35 ms | 2424 KB |
#include <bits/stdc++.h> #define mp make_pair #define pb push_back #define F first #define S second #define all(x) x.begin(),x.end() #define MAXN 200005 using namespace std; int n,q; bool dodat[MAXN]; int prvi=1,poslednji,prosli; void dp(){ while(dodat[prvi])prvi++; dodat[prvi]=true; printf("%d ",prvi); } void dk(){ while(dodat[poslednji])poslednji--; dodat[poslednji]=true; printf("%d ",poslednji); } int main() { int n; scanf("%d", &n); poslednji=n+n-1; scanf("%d",&prosli); dodat[prosli]=true; printf("%d ",prosli); for(int i=2;i<=n;i++){ int t; scanf("%d", &t); if(t==prosli){ dp(); dk(); }else if(prosli<t){ if(dodat[t])dk(); else{ dodat[t]=true; printf("%d ",t); } dk(); }else{ if(dodat[t])dp(); else{ dodat[t]=true; printf("%d ",t); } dp(); } prosli=t; } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 2 ms | 256 KB | Output is correct |
7 | Correct | 3 ms | 256 KB | Output is correct |
8 | Correct | 2 ms | 384 KB | Output is correct |
9 | Correct | 2 ms | 256 KB | Output is correct |
10 | Correct | 3 ms | 256 KB | Output is correct |
11 | Correct | 2 ms | 384 KB | Output is correct |
12 | Correct | 2 ms | 384 KB | Output is correct |
13 | Correct | 4 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 488 KB | Output is correct |
2 | Correct | 3 ms | 384 KB | Output is correct |
3 | Correct | 8 ms | 512 KB | Output is correct |
4 | Correct | 7 ms | 640 KB | Output is correct |
5 | Correct | 22 ms | 1024 KB | Output is correct |
6 | Correct | 27 ms | 1664 KB | Output is correct |
7 | Correct | 35 ms | 2424 KB | Output is correct |