Submission #1004579

#TimeUsernameProblemLanguageResultExecution timeMemory
1004579Valaki2Calvinball championship (CEOI15_teams)C++14
20 / 100
1098 ms604 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define mp make_pair #define pii pair<int, int> #define fi first #define se second void nxt(vector<int> &v) { int n = (int) v.size(); vector<int> prefmax(n); prefmax[0] = 1; for(int i = 1; i < n; i++) { prefmax[i] = max(prefmax[i - 1], v[i]); } if(prefmax[n - 1] == n) { // 1 2 3 ... n return; } for(int i = n - 1; i >= 0; i--) { if(prefmax[i - 1] >= v[i]) { v[i]++; return; } v[i] = 1; } } void solve() { int n; cin >> n; vector<int> v(n, 1); vector<int> goal(n); for(int i = 0; i < n; i++) { cin >> goal[i]; } int ans = 0; ans++; while(v != goal) { nxt(v); ans++; } cout << ans << "\n"; } signed main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); solve(); }
#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...