Submission #201488

#TimeUsernameProblemLanguageResultExecution timeMemory
201488EmmanuelACStudentsko (COCI14_studentsko)C++14
100 / 100
24 ms632 KiB
#include<bits/stdc++.h> using namespace std; int n, k; vector<int> v; void relabel(vector<int>& mv){ vector<int> aux(n); for(int i=0; i<n; i++) aux[i] = mv[i]; sort(aux.begin(), aux.end()); map<int, int> idx; for(int i=0; i<n; i++) idx[aux[i]] = i/k +1; for(int i=0; i<n; i++) mv[i] = idx[mv[i]]; } int lis(vector<int>& v){ int sol = 0; vector<int> lis(n +1); for(int i=0; i<n; i++){ int mx = 0; for(int j=0; j<=v[i]; j++) mx = max(mx, lis[j] ); lis[ v[i] ] = mx +1; sol = max(sol, lis[v[i]]); } return sol; } int main(){ scanf("%d %d", &n, &k); v.resize(n); for(int i=0; i<n; i++){ int aux; scanf("%d", &aux); v[i] = aux; } relabel(v); int sol = n - lis(v); printf("%d\n", sol); }

Compilation message (stderr)

studentsko.cpp: In function 'int main()':
studentsko.cpp:38:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &n, &k);
   ~~~~~^~~~~~~~~~~~~~~~~
studentsko.cpp:42:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     int aux; scanf("%d", &aux);
              ~~~~~^~~~~~~~~~~~
#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...