Submission #165112

# Submission time Handle Problem Language Result Execution time Memory
165112 2019-11-25T08:17:10 Z egekabas Studentsko (COCI14_studentsko) C++14
90 / 100
81 ms 65540 KB
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef unsigned long long   ull;
typedef long double ld;
typedef pair<int, int>    pll;
typedef pair<ull, ull>    pull;
typedef pair<int, int>  pii;
typedef pair<ld, ld>  pld;
int n, k;
int dp[5009][5009];
pii a[5009];
int team[5009];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    
    cin >> n >> k;
    for(int i = 0; i < n; ++i){
        cin >> a[i].ff;
        a[i].ss = i;
    }
    sort(a, a+n);
    for(int i = 0; i < n; ++i){
        team[a[i].ss] = i/k;
    }
    for(int i = 0; i < n; ++i){
        int mini = 1e9;
        for(int j = 0; j <= (n-1)/k; ++j){
            if(i == 0){
                dp[i][j] = 1;
                continue;
            }
            mini = min(mini, dp[i-1][j]);
            dp[i][j] = mini+1;
        }
        --dp[i][team[i]];
    }
    int ans = 1e9;
    for(int j = 0; j <= (n-1)/k; ++j)
        ans = min(ans, dp[n-1][j]);
    cout << ans << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 436 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 30 ms 26716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 21496 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 56 ms 56508 KB Output is correct
2 Correct 44 ms 44920 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 27512 KB Output is correct
2 Runtime error 81 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Correct 29 ms 30332 KB Output is correct
2 Correct 17 ms 18552 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 18 ms 20856 KB Output is correct
2 Correct 26 ms 25180 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 22124 KB Output is correct
2 Correct 21 ms 21240 KB Output is correct