Submission #443549

#TimeUsernameProblemLanguageResultExecution timeMemory
443549prvocisloTeams (CEOI11_tea)C++17
0 / 100
372 ms107592 KiB
#include <bits/stdc++.h> typedef long long ll; using namespace std; struct kid { int a, i; }; bool cmp(const kid &a, const kid &b) { return a.a > b.a; } struct nieco { int cnt, mini, pv; }; void upd(nieco &a, const nieco &b) { if (b.cnt > a.cnt || (a.cnt == b.cnt && a.mini > b.mini)) a = b; } int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<kid> v(n+1); for (int i = 1; i <= n; i++) cin >> v[i].a, v[i].i = i; sort(v.begin()+1, v.end(), cmp); vector<nieco> dp(n+1); vector<vector<int> > vj(2*n+5); dp[v[1].a] = { 1, v[1].a, 0 }; for (int i = v[1].a+1; i <= n; i++) { dp[i] = { dp[i-1].cnt, dp[i-1].mini, dp[i-1].pv }; if (dp[i-1].mini * 1ll * dp[i-1].cnt == (ll)i) dp[i].mini++; for (int j : vj[i+1]) upd(dp[i], { dp[j-1].cnt+1, max(dp[j-1].mini, i-j+1), j-1 }); vj[v[i].a + i].push_back(i); } cout << dp[n].cnt << "\n"; int r = n; while (r) { //cout << r << endl; int l = dp[r].pv; cout << r - l; for (int i = l+1; i <= r; i++) cout << " " << v[i].i; cout << "\n"; r = l; } return 0; }
#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...