Submission #1095593

# Submission time Handle Problem Language Result Execution time Memory
1095593 2024-10-02T15:34:24 Z 0pt1mus23 Studentsko (COCI14_studentsko) C++14
10 / 100
87 ms 21332 KB
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ins insert
#define pb push_back
#define putr(x) cout<<x<<endl;return;
#define all(x) x.begin(),x.end()
#define _ << " " <<  
const int   mod = 1e9+7 ,
            sze= 5000 + 23 ,
            inf = INT_MAX ,
            L = 31 ;
int dp[sze][sze];

void opt1z(){
    int n,k;
    cin>>n>>k;
    vector<int> arr(n),color(n);
    multiset<int> lst;
    map<int,vector<int>> idx;

    for(int i=0;i<n;i++){
        cin>>arr[i];
        idx[arr[i]].pb(i);
        lst.ins(arr[i]);
    }
    for(auto &v:idx){
        reverse(all(v.second));
    }
    int c = 1;
    int nm = 0;
    while(!lst.empty()){
        nm++;
        if(nm==k+1){
            nm=1;
            c++;
        }
        color[idx[*lst.begin()].back()]=c;
        idx[*lst.begin()].pop_back();
        lst.erase(lst.begin());
    }
    // for(auto v:color){
    //     cout<<v<<" ";
    // }
    // cout<<endl;
    int ans=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<i;j++){
            dp[i][color[i]] = max({dp[i][color[i]],dp[j][color[i] -1]+1, dp[j][color[i]] +1 });
            // cout<<i _ j _ color[i] _ dp[i][color[i]]<<endl;
        }
        dp[i][color[i]]=max(dp[i][color[i]],1);
        ans=max(ans,dp[i][color[i]]);
    }
    putr(n - ans);
}
 
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
 
    int tt = 1;
    // cin>>tt;
    while(tt--){
        opt1z();
    }
 
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 67 ms 20664 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 67 ms 21328 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 52 ms 18932 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 60 ms 20352 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 67 ms 21260 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 87 ms 21332 KB Output is correct
2 Incorrect 66 ms 20812 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 66 ms 21072 KB Output isn't correct
2 Halted 0 ms 0 KB -