#include<cstdio>
#include<algorithm>
#include<set>
int s[50001];
int b[5000000];
std::set<int> st;
int main()
{
int n,m,i,mx=-987654321;
scanf("%d",&n);
for(i=1;i<=n;i++)
scanf("%d",&s[i]),b[i]=s[i],st.insert(s[i]),mx=std::max(mx,s[i]);
std::set<int>::iterator k=st.upper_bound(st.size()-1);
scanf("%d",&m);
/*for(i=1;i<=m;i++)
{
if(*k>mx)
{
if(i<=n) printf("%d",b[i]);
else printf("%d",st.size()+i-n-1);
}
else
{
if(i<=n) printf("%d",b[i]);
else if(i<=n+(*k-st.size()+1)) printf("%d",i-n-1+st.size());
else printf("%d",*k);
}
printf(" ");
}
printf("\n------------------------------\n");
for(i=1;i<=m;i++)
{
if(i<=n) printf("%d",b[i]);
else printf("%d",b[i]=st.size()),st.insert(b[i]);
printf(" ");
}*/
if(*k>mx)
{
if(m<=n) printf("%d",b[m]);
else printf("%d",st.size()+m-n-1);
}
else
{
if(m<=n) printf("%d",b[m]);
else if(m<=n+(*k-st.size()+1)) printf("%d",m-n-1+st.size());
else printf("%d",*k);
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
20940 KB |
Output is correct |
2 |
Correct |
0 ms |
20940 KB |
Output is correct |
3 |
Correct |
0 ms |
20940 KB |
Output is correct |
4 |
Correct |
0 ms |
20940 KB |
Output is correct |
5 |
Correct |
0 ms |
20940 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
20940 KB |
Output is correct |
2 |
Correct |
0 ms |
20940 KB |
Output is correct |
3 |
Correct |
0 ms |
20940 KB |
Output is correct |
4 |
Correct |
0 ms |
20940 KB |
Output is correct |
5 |
Correct |
0 ms |
20940 KB |
Output is correct |
6 |
Correct |
0 ms |
20940 KB |
Output is correct |
7 |
Correct |
0 ms |
20940 KB |
Output is correct |
8 |
Correct |
0 ms |
20940 KB |
Output is correct |
9 |
Correct |
0 ms |
20940 KB |
Output is correct |
10 |
Correct |
0 ms |
20940 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
20940 KB |
Output is correct |
2 |
Correct |
8 ms |
20940 KB |
Output is correct |
3 |
Correct |
0 ms |
21336 KB |
Output is correct |
4 |
Correct |
2 ms |
20940 KB |
Output is correct |
5 |
Correct |
22 ms |
22920 KB |
Output is correct |
6 |
Correct |
4 ms |
20940 KB |
Output is correct |
7 |
Correct |
0 ms |
21336 KB |
Output is correct |
8 |
Correct |
25 ms |
22392 KB |
Output is correct |
9 |
Correct |
7 ms |
20940 KB |
Output is correct |
10 |
Correct |
5 ms |
20940 KB |
Output is correct |
11 |
Correct |
9 ms |
20940 KB |
Output is correct |
12 |
Correct |
18 ms |
21468 KB |
Output is correct |
13 |
Correct |
19 ms |
23184 KB |
Output is correct |
14 |
Correct |
29 ms |
23184 KB |
Output is correct |
15 |
Correct |
0 ms |
21204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
23184 KB |
Output is correct |
2 |
Correct |
26 ms |
22392 KB |
Output is correct |
3 |
Correct |
9 ms |
20940 KB |
Output is correct |
4 |
Correct |
3 ms |
20940 KB |
Output is correct |
5 |
Correct |
2 ms |
20940 KB |
Output is correct |
6 |
Correct |
23 ms |
23184 KB |
Output is correct |
7 |
Correct |
23 ms |
22920 KB |
Output is correct |
8 |
Correct |
16 ms |
21468 KB |
Output is correct |
9 |
Correct |
0 ms |
20940 KB |
Output is correct |
10 |
Correct |
4 ms |
20940 KB |
Output is correct |
11 |
Correct |
5 ms |
21336 KB |
Output is correct |
12 |
Correct |
5 ms |
20940 KB |
Output is correct |
13 |
Correct |
0 ms |
21204 KB |
Output is correct |
14 |
Correct |
0 ms |
20940 KB |
Output is correct |
15 |
Correct |
7 ms |
20940 KB |
Output is correct |