Submission #578292

# Submission time Handle Problem Language Result Execution time Memory
578292 2022-06-16T10:28:06 Z Trisanu_Das Studentsko (COCI14_studentsko) C++17
100 / 100
45 ms 468 KB
#include <bits/stdc++.h> 
using namespace std;
#define pii pair<int, int>

 
int main() {
  int N, K; cin >> N >> K;
  vector<pii> a;
  vector<int> tb;
  for(int i = 0; i < N; i++) {
    int x; cin >> x;
    a.push_back(pii(x, i));
  }
  sort(a.begin(), a.end());
  vector<int> pos(N);
  for(int i = 0; i < N; i++) {
    pos[a[i].second] = i / K;
  }
  int ans = 0;
  for(int i = 0; i < N; i++) {
    int opt = 0;
    for(int j = 0; j < i; j++) if(pos[j] <= pos[i]) opt = max(opt, tb[j]);
    tb.push_back(opt + 1);
    ans = max(opt+1, ans);
  }
  cout << N - ans << '\n';
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 36 ms 424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 37 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 30 ms 340 KB Output is correct
2 Correct 33 ms 436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 35 ms 436 KB Output is correct
2 Correct 44 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 45 ms 448 KB Output is correct
2 Correct 25 ms 436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 41 ms 456 KB Output is correct
2 Correct 38 ms 440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 43 ms 444 KB Output is correct
2 Correct 35 ms 444 KB Output is correct