Submission #88777

#TimeUsernameProblemLanguageResultExecution timeMemory
88777tushar_2658Studentsko (COCI14_studentsko)C++14
0 / 100
4 ms500 KiB
#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 (stderr)

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]);
   ~~~~~^~~~~~~~~~~~~~~~~
#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...