답안 #14014

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
14014 2015-04-25T00:23:35 Z pjsdream 이상한 수열 (OJUZ10_bizarre) C++
컴파일 오류
0 ms 0 KB
#pragma warning(disable:4996)

#include <stdio.h>
#include <set>
using namespace std;

int n, m;
int a[50000];
set<int> s;

int main()
{
	scanf("%d", &n);
	for (int i=0; i<n; i++) scanf("%d", &a[i]), s.insert(a[i]);
	scanf("%d", &m);

	if (m<=n) {
		printf("%d\n", a[m-1]);
	}
	else {
		m -= n+1;

		int b = s.size();
		int e;

		// B_n+1 = b

		auto it = s.lower_bound(b);
		if (it == s.end()) e = 2000000000;
		else e = *it;

		if (b+m <= e) printf("%d\n", b+m);
		else printf("%d\n", e);
	}

	return 0;
}

Compilation message

bizarre.cpp:1:0: warning: ignoring #pragma warning  [-Wunknown-pragmas]
 #pragma warning(disable:4996)
 ^
bizarre.cpp: In function ‘int main()’:
bizarre.cpp:28:3: warning: ‘auto’ changes meaning in C++11; please remove it [-Wc++0x-compat]
   auto it = s.lower_bound(b);
   ^
bizarre.cpp:28:8: error: ‘it’ does not name a type
   auto it = s.lower_bound(b);
        ^
bizarre.cpp:29:7: error: ‘it’ was not declared in this scope
   if (it == s.end()) e = 2000000000;
       ^
bizarre.cpp:13:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
                 ^
bizarre.cpp:14:60: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  for (int i=0; i<n; i++) scanf("%d", &a[i]), s.insert(a[i]);
                                                            ^
bizarre.cpp:15:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &m);
                 ^