답안 #543194

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
543194 2022-03-29T18:30:17 Z ahmet34 학생 (COCI14_studentsko) C++14
100 / 100
49 ms 416 KB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using pii = pair<int, int>;
#define all(x) x.begin(), x.end()

const int INF = 2e9, N = 55, M = 998244353, LOG = 16;
const ll LINF = 1e18;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n, k; 
    cin >> n >> k;

    vector<int> v(n), p(n);
    for(int& x: v) cin >> x;

    iota(all(p), 0);
    sort(all(p), [&](int i, int j) {
        return v[i] < v[j];
    });

    for(int i = 0; i < n; i++) 
        v[p[i]] = i / k;
        
    vector<int> dp(n, 1);

    for(int i = 0; i < n; i++) 
        for(int j = 0; j < i; j++)
            if(v[j] <= v[i])
                dp[i] = max(dp[i], dp[j] + 1);
    
    cout << n - *max_element(all(dp));
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 352 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 43 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 35 ms 340 KB Output is correct
2 Correct 32 ms 400 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 36 ms 340 KB Output is correct
2 Correct 43 ms 412 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 49 ms 356 KB Output is correct
2 Correct 39 ms 400 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 340 KB Output is correct
2 Correct 49 ms 416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 41 ms 340 KB Output is correct
2 Correct 42 ms 412 KB Output is correct