답안 #88777

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
88777 2018-12-08T16:20:40 Z tushar_2658 학생 (COCI14_studentsko) C++14
0 / 100
4 ms 500 KB
#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;
int n, k, cnt = 0;
ll arr[maxn];
map<ll, ll>mark;
vector<ll> vec, vec1;
int dp[maxn];
ll t[maxn];
int CeilIndex(std::vector<ll>& v, int l, int r, int key) 
{ 
    while (r - l > 1) { 
        int m = l + (r - l) / 2; 
        if (v[m] >= key) 
            r = m; 
        else
            l = m; 
    } 
  
    return r; 
} 
  
int LongestIncreasingSubsequenceLength(std::vector<ll>& v) 
{ 
    if (v.size() == 0) 
        return 0; 
  
    std::vector<ll> tail(v.size(), 0); 
    int length = 1;
  
    tail[0] = v[0]; 
    for (size_t i = 1; i < v.size(); i++) { 
        if (v[i] < tail[0]) 
            tail[0] = v[i];
        else if (v[i] >= tail[length - 1]) 
            tail[length++] = v[i];
        else
            tail[CeilIndex(tail, -1, length - 1, v[i])] = v[i]; 
    } 
  
    return length; 
} 

int solve(){
	for(int i=0; i<n; i++)vec1.pb(mark[arr[i]]);
	int lon = 0;
	return n - LongestIncreasingSubsequenceLength(vec1);
}

int main(){
	file
	//fastread
	scanf("%d%d", &n, &k);
	for(int i=0; i<n; i++){
		scanf("%lld", &arr[i]);
		vec.pb(arr[i]);
	}
	//vec1 = vec;
	sort(all(vec));
	for(int i=0; i<n; i++){
		if(i%k == 0)++cnt;
		mark[vec[i]] = cnt;
	}
	printf("%d", solve());
}

Compilation message

studentsko.cpp: In function 'int solve()':
studentsko.cpp:55:6: warning: unused variable 'lon' [-Wunused-variable]
  int lon = 0;
      ^~~
studentsko.cpp: In function 'int main()':
studentsko.cpp:5:21: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
 #define file freopen("in.txt", "r", stdin);
              ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
studentsko.cpp:60:2: note: in expansion of macro 'file'
  file
  ^~~~
studentsko.cpp:62:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &n, &k);
  ~~~~~^~~~~~~~~~~~~~~~
studentsko.cpp:64:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld", &arr[i]);
   ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 372 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 448 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 448 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 476 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 476 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 476 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 476 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 500 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 500 KB Output isn't correct
2 Halted 0 ms 0 KB -