Submission #665144

#TimeUsernameProblemLanguageResultExecution timeMemory
665144true22Studentsko (COCI14_studentsko)C++14
0 / 100
1091 ms844 KiB
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef long double ld; typedef pair<ll, ll> pl; typedef vector<ll> vl; typedef vector<pl> vp; #define nl "\n" #define fr first #define sc second #define pb push_back #define all(x) x.begin(), x.end() #define fur(i, a, b) for(ll i = a; i <= b; ++i) #define ruf(i, a, b) for(ll i = a; i >= b; --i) #define pv(x) for(auto k : x){cout << k << " ";} cout << nl const ll inf = 1e17; void solve(){ ll n, k; cin >> n >> k; vl a(n); fur(i, 0, n-1) cin >> a[i]; vl b = a; sort(all(b)); ll ans = inf; fur(i, 0, (1<<n)-1){ ll bm = i; set<ll> tof; vl seq; fur(j, 0, n-1){ if ((1<<j) & i){ tof.insert(j); }else{ seq.pb(a[j]); } } for(auto u: tof) seq.pb(a[u]); // seq = {2, 1, 7, 5, 10, 16}; bool val = 1; vl tmp; ll t = 0; ruf(x, n-1, 0){ t++; tmp.pb(seq[x]); if (t+1 > k){ sort(all(tmp)); //pv(tmp); fur(m, 0, k-1){ if (tmp[m] != b[m+x]){ val = 0; break; } } t = 0; tmp.clear(); } } if (val){ //pv(seq); //cout << tof.size() << nl; ans = min(ans, (ll)tof.size()); } } cout << ans << nl; } int main(){ ios::sync_with_stdio(0); cin.tie(0); ll t = 1; //cin >> t; while(t--){ solve(); } return 0; }

Compilation message (stderr)

studentsko.cpp: In function 'void solve()':
studentsko.cpp:32:12: warning: unused variable 'bm' [-Wunused-variable]
   32 |         ll bm = 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...