제출 #14415

#제출 시각아이디문제언어결과실행 시간메모리
14415hakgb11이상한 수열 (OJUZ10_bizarre)C++98
0 / 100
14 ms1916 KiB
#include <iostream>
#include <fstream>
#include <string>
#include <string.h>
#include <queue>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <limits.h>

typedef long long ll;
using namespace std;

int n, m, t;

int main()
{
#ifdef _CONSOLE
	freopen("input.txt", "r", stdin);
#endif
	int n;
	scanf("%d", &n);
	vector<int> vi(n);
	for (int i = 0; i < n; i++){
		scanf("%d", &vi[i]);
	}
	sort(vi.begin(), vi.end());
	vi.resize(unique(vi.begin(), vi.end()) - vi.begin());
	scanf("%d", &m);
	vector<int>::iterator itor = lower_bound(vi.begin(), vi.end(), vi.size());
	if (itor == vi.end()){
		printf("%d\n", (m - n) + (vi.size() - 1));
	}
	else{
		if(*itor + vi.size() - 1 <= m )
			printf("%d\n", *itor);
		else{
			printf("%d\n", (m - n) + (vi.size() - 1));

		}
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...