Submission #201488

# Submission time Handle Problem Language Result Execution time Memory
201488 2020-02-10T17:40:38 Z EmmanuelAC Studentsko (COCI14_studentsko) C++14
100 / 100
24 ms 632 KB
#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

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 time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 632 KB Output is correct
2 Correct 12 ms 632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 632 KB Output is correct
2 Correct 24 ms 632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 632 KB Output is correct
2 Correct 7 ms 632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 632 KB Output is correct
2 Correct 8 ms 552 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 632 KB Output is correct
2 Correct 8 ms 632 KB Output is correct