Submission #83546

#TimeUsernameProblemLanguageResultExecution timeMemory
83546leejseo이상한 수열 (OJUZ10_bizarre)C++14
62 / 100
1078 ms6344 KiB
#include <bits/stdc++.h> using namespace std; int N, M; int S[50001]; set<int> T; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cin >> N; for (int i=1; i<=N; i++){ cin >> S[i]; T.insert(S[i]); } cin >> M; if (M <= N){ cout << S[M] << endl; return 0; } if ((signed) T.size() > *T.rbegin()){ cout << T.size() + M - N - 1 << endl; return 0; } int i = N+1; while (1){ if (i == M){ cout << T.size() << endl; return 0; } if (T.lower_bound(T.size()) != T.end()){ T.insert(T.size()); i++; continue; } cout << T.size() + M - i << endl; return 0; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...