제출 #674634

#제출 시각아이디문제언어결과실행 시간메모리
674634tamthegodTeams (CEOI11_tea)C++14
0 / 100
2576 ms31224 KiB
// Make the best become better // No room for laziness #include<bits/stdc++.h> #define int long long #define pb push_back #define fi first #define se second using namespace std; using ll = long long; using ld = long double; using ull = unsigned long long; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int maxN = 1e6 + 5; const int mod = 1e9 + 7; const ll oo = 1e18; int n, a[maxN], id[maxN]; int f[maxN], trace[maxN]; int pos[maxN]; void ReadInput() { cin >> n; for(int i=1; i<=n; i++) cin >> a[i]; } void Solve() { iota(id + 1, id + n + 1, 1); sort(id + 1, id + n + 1, [](int i, int j) { return a[i] < a[j]; }); memset(f, -3, sizeof f); f[0] = 0; for(int i=1; i<=n; i++) { int t = id[i]; for(int j=i-a[t]+1; j>=1; j--) { if(f[i] < f[j - 1] + 1) { f[i] = f[j - 1] + 1; trace[i] = j; } } } cout << f[n] << '\n'; int i = n; while(i) { cout << i - trace[i] + 1 << " "; for(int j=i; j>=trace[i]; j--) cout << id[j] << " "; i = trace[i] - 1; cout << '\n'; } } int32_t main() { //freopen("x.inp", "r", stdin); ios_base::sync_with_stdio(false); cin.tie(nullptr); ReadInput(); 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...