Submission #919125

#TimeUsernameProblemLanguageResultExecution timeMemory
919125TINStudentsko (COCI14_studentsko)C++17
100 / 100
4 ms828 KiB
#include <bits/stdc++.h> using namespace std; #define FNAME "test" const int N = 5005; int n,k; int v[N], x[N]; int group = 1; map<int,int> mp; int g[N]; int dp[N]; void Task() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout << fixed << setprecision(9); if (fopen(FNAME".inp","r")) { freopen(FNAME".inp","r",stdin); freopen(FNAME".out","w",stdout); } } void Solve() { //Your Code cin >> n >> k; for (int i = 1; i <= n; i++) { cin >> v[i]; x[i] = v[i]; } sort(x + 1, x + n + 1); for (int i = 1; i <= n; i++) { mp[x[i]] = group; if (i % k == 0) group++; } for (int i = 1; i <= n; i++) g[i] = mp[v[i]]; for (int i = 0; i <= n; i++) dp[i] = -1; dp[0] = 0; int mx = 0; for (int i = 1; i <= n; i++) { if (dp[mx] <= g[i]) { ++mx; dp[mx] = g[i]; } else { for (int j = mx - 1; j >= 0; j--) if (dp[j] <= g[i]) dp[j + 1] = min(dp[j + 1], g[i]); } } cout << n - mx << '\n'; } int main() { Task(); Solve(); cerr << "\nTime run: " << 1000*clock()/CLOCKS_PER_SEC << "ms"; return 37^37; }

Compilation message (stderr)

studentsko.cpp: In function 'void Task()':
studentsko.cpp:21:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |   freopen(FNAME".inp","r",stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
studentsko.cpp:22:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |   freopen(FNAME".out","w",stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#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...