Submission #74405

#TimeUsernameProblemLanguageResultExecution timeMemory
74405nixysStudentsko (COCI14_studentsko)C++11
100 / 100
6 ms1004 KiB
#include <bits/stdc++.h> #define fi first #define se second #define mp make_pair #define pb push_back using namespace std; typedef pair <int, int> pii; typedef long long ll; const int inf = 1e9 + 1; const double eps = 1e-9; const int MAXN = 5001; int n, k; int a[MAXN]; vector <pii> v; vector <int> najmanji; int main(){ cin >> n >> k; for (int i = 0; i < n; i++){ cin >> a[i]; v.pb(mp(a[i], i)); } sort(v.begin(), v.end()); for (int i = 0; i < n; i++) a[v[i].se] = (i/k)+1; najmanji.pb(-inf); for (int i = 0; i < n; i++){ vector<int>::iterator it = upper_bound(najmanji.begin(), najmanji.end(), a[i]); if (it == najmanji.end()) najmanji.pb(a[i]); else *it = a[i]; } cout << n - najmanji.size() + 1; return 0; }
#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...