Submission #270934

#TimeUsernameProblemLanguageResultExecution timeMemory
270934leductoanStudentsko (COCI14_studentsko)C++14
100 / 100
47 ms516 KiB
#include<bits/stdc++.h> using namespace std; #define task "" #define BIT(x, i) (((x) >> (i)) & 1) #define lb lower_bound #define ub upper_bound #define lla(v) (v).begin(),(v).end() #define zs(v) (v).size() #define fi first #define se second #define pb push_back typedef long double ld; typedef long long ll; typedef pair<int,int> pii; const int mod=1000000007; /// 998244353 const int base=311; const int N=1e5+5; pii a[5005]; int n,k,b[5005],dp[5005]; void solved() { cin>>n>>k; for(int i=0;i<n;++i) cin>>a[i].fi,a[i].se=i; sort(a,a+n); for(int i=0;i<n;++i) b[a[i].se]=i/k; int ans=0; for(int i=0;i<n;++i) { dp[i]=1; for(int j=0;j<i;++j) if(b[j]<=b[i]) dp[i]=max(dp[i],dp[j]+1); ans=max(ans,dp[i]); } cout<<n-ans; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); if(fopen(task".inp","r")) { freopen(task".inp","r",stdin); freopen(task".out","w",stdout); } solved(); }

Compilation message (stderr)

studentsko.cpp: In function 'int main()':
studentsko.cpp:42:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   42 |         freopen(task".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
studentsko.cpp:43:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   43 |         freopen(task".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...