Submission #918791

# Submission time Handle Problem Language Result Execution time Memory
918791 2024-01-30T12:40:44 Z vjudge1 Studentsko (COCI14_studentsko) C++17
100 / 100
38 ms 572 KB
#include<bits/stdc++.h>
using namespace std;
#define ll int
#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],dp[2][N];


int main() {
	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;
	}
	for(int i=n; i>=1; i--) {
		for(int j=0; j<=n; j++) {
			dp[i%2][j] = dp[(i+1)%2][j];
			if(a[i] >= j) {
				dp[i%2][j] = max(dp[i%2][j],dp[(i+1)%2][a[i]]+1);
			}
			
		}
	}
	cout << n - dp[1][0] << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 34 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 18 ms 348 KB Output is correct
2 Correct 16 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 572 KB Output is correct
2 Correct 38 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 344 KB Output is correct
2 Correct 14 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 344 KB Output is correct
2 Correct 18 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 344 KB Output is correct
2 Correct 18 ms 344 KB Output is correct