Submission #88778

# Submission time Handle Problem Language Result Execution time Memory
88778 2018-12-08T16:21:24 Z tushar_2658 Studentsko (COCI14_studentsko) C++14
20 / 100
8 ms 1056 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: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]);
   ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 252 KB Output is correct
2 Correct 2 ms 372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 392 KB Output is correct
2 Correct 2 ms 392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 980 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 980 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 980 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 1056 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 1056 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 1056 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 1056 KB Output isn't correct
2 Halted 0 ms 0 KB -