답안 #201488

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
201488 2020-02-10T17:40:38 Z EmmanuelAC 학생 (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);
              ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 632 KB Output is correct
2 Correct 12 ms 632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 632 KB Output is correct
2 Correct 24 ms 632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 632 KB Output is correct
2 Correct 7 ms 632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 632 KB Output is correct
2 Correct 8 ms 552 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 632 KB Output is correct
2 Correct 8 ms 632 KB Output is correct