답안 #276922

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
276922 2020-08-20T18:59:30 Z wutwere 학생 (COCI14_studentsko) C++17
100 / 100
162 ms 512 KB
#include <bits/stdc++.h>
using namespace std;

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	int n, k; cin >> n >> k;
	vector<int> v(n);
	for (int i = 0; i < n ; i++)
		cin >> v[i];
	vector<int> sortedv = v;
	sort(sortedv.begin(), sortedv.end());
	for (int i = 0; i < n / k; i++) {
		set<int> s;
		for (int j = 0; j < k; j++) {
			s.insert(sortedv[i * k + j]);
		}
		int p = 0;
		for (int j = 0; j < n; j++) {
			if (s.count(v[j])) {
				v[j] = sortedv[i * k + p];
				p++;
			}
		}
	}
	vector<int> dp(n, 1);
	int longest = 1;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < i; j++) {
			if (v[i] > v[j]) {
				dp[i] = max(dp[i], dp[j] + 1);
			}
		}
		longest = max(longest, dp[i]);
	}
	cout << n - longest;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 55 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 52 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 86 ms 384 KB Output is correct
2 Correct 73 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 55 ms 384 KB Output is correct
2 Correct 162 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 66 ms 384 KB Output is correct
2 Correct 26 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 45 ms 384 KB Output is correct
2 Correct 49 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 48 ms 488 KB Output is correct
2 Correct 45 ms 384 KB Output is correct