Submission #88785

#TimeUsernameProblemLanguageResultExecution timeMemory
88785tushar_2658Studentsko (COCI14_studentsko)C++14
100 / 100
10 ms1564 KiB
#include "bits/stdc++.h" using namespace std; typedef long long ll; #define file freopen("in.txt", "r", stdin); #define pii pair<int,int> #define pb push_back #define all(v) v.begin(), v.end() #define keepunique(v) (v).erase(unique(all(v)),v.end()) #define fastread ios_base::sync_with_stdio(false);cin.tie(NULL); const int maxn = 5005; ll inf = 1e17; map<ll, ll>mark; ll arr[maxn]; vector<ll>vec; int n, k; int lis(){ int ans = 0; ll t[n+1]; t[0] = -inf; for(int i=1; i<=n; i++)t[i] = inf; for(int i=0; i<n; i++){ int hi = ans, lo = 0; while(lo <= hi){ int mid = (lo+hi)>>1; if(t[mid] <= mark[arr[i]])lo = mid+1; else hi = mid-1; } t[lo]=mark[arr[i]]; ans = max(ans, lo); } return ans; } int main(){ //file fastread cin>>n>>k; for(int i=0; i<n; i++){ cin>>arr[i]; vec.pb(arr[i]); } sort(all(vec)); int cnt = 0; for(int i=0; i<n; i++){ if(i%k == 0)++cnt; mark[vec[i]]=cnt; } cout<<n-lis()<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...