Submission #250660

#TimeUsernameProblemLanguageResultExecution timeMemory
250660kingfran1907Studentsko (COCI14_studentsko)C++14
100 / 100
44 ms512 KiB
#include <bits/stdc++.h> using namespace std; typedef long long llint; const int maxn = 5010; const int inf = 0x3f3f3f3f; int n, k; int niz[maxn]; vector< int > v; int dp[maxn]; int main() { scanf("%d%d", &n, &k); for (int i = 0; i < n; i++) scanf("%d", niz+i); for (int i = 0; i < n; i++) v.push_back(niz[i]); sort(v.begin(), v.end()); for (int i = 0; i < n; i++) niz[i] = lower_bound(v.begin(), v.end(), niz[i]) - v.begin(); for (int i = 0; i < n; i++) niz[i] /= k; int sol = 0; for (int i = 0; i < n; i++) { dp[i] = 0; for (int j = 0; j < i; j++) { if (niz[j] <= niz[i]) dp[i] = max(dp[i], dp[j]); } dp[i]++; sol = max(sol, dp[i]); } printf("%d", n - sol); return 0; }

Compilation message (stderr)

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