Submission #492340

#TimeUsernameProblemLanguageResultExecution timeMemory
492340aris12345678Studentsko (COCI14_studentsko)C++14
20 / 100
2 ms332 KiB
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> pii; #define X first #define Y second const int mxN = 5005; pii v[mxN]; int main() { int n, k; scanf("%d %d", &n, &k); for(int i = 0; i < n; i++) { scanf("%d", &v[i].X); v[i].Y = i; } sort(v, v+n); vector<int> pos(n); for(int i = 0; i < n; i++) pos[v[i].Y] = i/k; vector<int> dp; for(int i = 0; i < n; i++) { if(dp.empty()) dp.push_back(pos[i]); else if(dp[int(dp.size()-1)] <= pos[i]) dp.push_back(pos[i]); else { int p = lower_bound(dp.begin(), dp.end(), pos[i])-dp.begin(); dp[p] = pos[i]; } } printf("%d\n", n-int(dp.size())); return 0; }

Compilation message (stderr)

studentsko.cpp: In function 'int main()':
studentsko.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     scanf("%d %d", &n, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~
studentsko.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         scanf("%d", &v[i].X);
      |         ~~~~~^~~~~~~~~~~~~~~
#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...