Submission #918774

# Submission time Handle Problem Language Result Execution time Memory
918774 2024-01-30T12:25:33 Z vjudge1 Studentsko (COCI14_studentsko) C++17
0 / 100
17 ms 65536 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<ll,ll>
#define pb push_back
#define fi first
#define se second

const ll N = 5003;

ll n,k;
pii q[N];
ll a[N],memo[N][N];

ll dp(ll x, ll y) {
	if(x == n+1) return 0;
	ll temp = memo[x][y];
	if(temp != -1) return temp;
	temp = dp(x+1,y);
	if(a[x] >= y) {
		temp = max(temp,dp(x+1,a[x])+1);
	}
	return memo[x][y] = temp;
}

int main() {
	memset(memo,-1,sizeof(memo));
	cin >> n >> k;
	for(int i=1; i<=n; i++) {
		cin >> q[i].fi;
		q[i].se = i;
	}
	sort(q+1,q+n+1);
	for(int i=1; i<=n; i++) {
		a[q[i].se] = (i-1)/k + 1;
	}
	cout << n - dp(1,0) << endl;
}
# Verdict Execution time Memory Grader output
1 Runtime error 17 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 14 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 14 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 15 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 15 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 15 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 15 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 14 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 15 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 15 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -