답안 #756880

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
756880 2023-06-12T10:59:46 Z KN200711 중앙값 배열 (balkan11_medians) C++14
5 / 100
47 ms 4156 KB
# include <bits/stdc++.h>
using namespace std;

int ct[200001];
int mn, mx, N;

void upd() {
	while(ct[mn] && mn <= N) mn++;
	while(ct[mx] && mx > 0) mx--;
}

int main() {
	scanf("%d", &N);
	vector<int> arr(N);
	for(int i=0;i<N;i++) scanf("%d", &arr[i]);
	vector<int> as;
	as.clear();
	mn = 1;
	mx = 2 * N - 1;
	for(int i=0;i<N;i++) {
		if(i == 0) {
			as.push_back(arr[i]);
			ct[arr[i]]++;
		}
		else {
			upd();
			if(arr[i] > arr[i - 1]) {
				as.push_back(arr[i]);
				as.push_back(mx);
			} else if(arr[i] < arr[i - 1]) {
				as.push_back(arr[i]);
				as.push_back(mn);
			} else {
				as.push_back(mn);
				as.push_back(mx);
			}
			ct[as.back()] = 1;
			ct[as[as.size() - 2]] = 1;
		}
	}
	for(int p=0;p<as.size();p++) printf("%d ", as[p]);
	printf("\n");
	return 0;
}

Compilation message

medians.cpp: In function 'int main()':
medians.cpp:41:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |  for(int p=0;p<as.size();p++) printf("%d ", as[p]);
      |              ~^~~~~~~~~~
medians.cpp:13:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |  scanf("%d", &N);
      |  ~~~~~^~~~~~~~~~
medians.cpp:15:28: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |  for(int i=0;i<N;i++) scanf("%d", &arr[i]);
      |                       ~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Not a permutation
2 Incorrect 1 ms 212 KB Not a permutation
3 Incorrect 1 ms 320 KB Not a permutation
4 Incorrect 1 ms 312 KB Not a permutation
5 Incorrect 1 ms 212 KB Not a permutation
6 Correct 1 ms 212 KB Output is correct
7 Incorrect 1 ms 308 KB Not a permutation
8 Incorrect 1 ms 212 KB Not a permutation
9 Incorrect 1 ms 320 KB Not a permutation
10 Incorrect 1 ms 212 KB Not a permutation
11 Incorrect 1 ms 212 KB Not a permutation
12 Incorrect 1 ms 312 KB Not a permutation
13 Incorrect 1 ms 340 KB Not a permutation
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Not a permutation
2 Incorrect 2 ms 468 KB Not a permutation
3 Incorrect 3 ms 596 KB Not a permutation
4 Incorrect 6 ms 960 KB Not a permutation
5 Incorrect 11 ms 1552 KB Not a permutation
6 Incorrect 29 ms 2736 KB Not a permutation
7 Incorrect 47 ms 4156 KB Not a permutation