# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
81631 | 2018-10-25T16:13:06 Z | xiaowuc1 | Studentsko (COCI14_studentsko) | C++14 | 64 ms | 1348 KB |
#include <bits/stdc++.h> /* unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count(); mt19937 g1.seed(seed1); ios_base::sync_with_stdio(false); cin.tie(NULL); */ using namespace std; const double PI = 2 * acos(0); typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> pii; typedef pair<int, ll> pill; typedef pair<ll, ll> pll; typedef long double ld; typedef vector<vector<ll>> matrix; int n, k; int l[5005]; int actual[5005]; int sorted[5005]; int dp[5005]; int getidx(int v) { return lower_bound(sorted, sorted+n, v) - sorted; } int main() { scanf("%d%d", &n, &k); for(int i = 0; i < n; i++) { scanf("%d", &l[i]); sorted[i] = l[i]; } sort(sorted, sorted+n); for(int i = 0; i < n; i++) { actual[i] = getidx(l[i]) / k; } int ret = 0; for(int i = 0; i < n; i++) { dp[i] = 1; for(int j = 0; j < i; j++) { if(actual[i] >= actual[j]) { dp[i] = max(dp[i], dp[j] + 1); } } ret = max(dp[i], ret); } printf("%d\n", n - ret); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 508 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 508 KB | Output is correct |
2 | Correct | 2 ms | 512 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 560 KB | Output is correct |
2 | Correct | 2 ms | 580 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 45 ms | 708 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 48 ms | 788 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 42 ms | 860 KB | Output is correct |
2 | Correct | 40 ms | 924 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 45 ms | 988 KB | Output is correct |
2 | Correct | 48 ms | 988 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 48 ms | 988 KB | Output is correct |
2 | Correct | 30 ms | 1132 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 48 ms | 1204 KB | Output is correct |
2 | Correct | 48 ms | 1232 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 64 ms | 1232 KB | Output is correct |
2 | Correct | 48 ms | 1348 KB | Output is correct |