답안 #88775

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
88775 2018-12-08T16:00:06 Z tushar_2658 학생 (COCI14_studentsko) C++14
30 / 100
1000 ms 972 KB
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
#define file freopen("in.txt", "r", stdin);
#define pii pair<int,int>
#define pb push_back
#define all(v) v.begin(), v.end()
#define keepunique(v)   (v).erase(unique(all(v)),v.end())
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);

const int maxn = 5005;
int n, k, cnt = 0;
ll arr[maxn];
map<ll, ll>mark;
vector<ll> vec;
int dp[maxn];
int call(int u){
	int ans = 0;
	if(dp[u] != -1)return dp[u];
	for(int i=u+1; i<n; i++){
		if(mark[arr[i]] >= mark[arr[u]]){
			if(call(i) >= ans)ans = call(i);
		}
	}
	return dp[u] = 1+ans;
}

int solve(){
	int lon = 0;
	for(int i=0; i<n; i++){
		memset(dp, -1, sizeof dp);
		lon = max(lon, call(i));
	}
	return n - lon;
}

int main(){
	//file
	//fastread
	scanf("%d%d", &n, &k);
	for(int i=0; i<n; i++){
		scanf("%lld", &arr[i]);
		vec.pb(arr[i]);
	}
	//vec1 = vec;
	sort(all(vec));
	for(int i=0; i<n; i++){
		if(i%k == 0)++cnt;
		mark[vec[i]] = cnt;
	}
	printf("%d", solve());
}

Compilation message

studentsko.cpp: In function 'int main()':
studentsko.cpp:41:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &n, &k);
  ~~~~~^~~~~~~~~~~~~~~~
studentsko.cpp:43:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld", &arr[i]);
   ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 464 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 464 KB Output is correct
2 Correct 2 ms 464 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 516 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1022 ms 816 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1075 ms 944 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1061 ms 944 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1049 ms 944 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1035 ms 972 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1051 ms 972 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1057 ms 972 KB Time limit exceeded
2 Halted 0 ms 0 KB -