# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
264167 |
2020-08-14T05:25:04 Z |
임성재(#5088) |
Teams (CEOI11_tea) |
C++17 |
|
518 ms |
31064 KB |
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false); cin.tie(0);
#define pre(a) cout << fixed; cout.precision(a);
#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf = 1e9;
const ll INF = 1e18;
int n;
vector<pii> v;
int tree[4000010];
int dp[1000010];
int pre[1000010];
void init(int node, int s, int e) {
tree[node] = -inf;
if(s == e) return;
init(node*2, s, (s+e)/2);
init(node*2+1, (s+e)/2+1, e);
}
void update(int node, int s, int e, int i, int x) {
if(s == e) {
tree[node] = x;
return;
}
int m = (s+e)/2;
if(i <= m) update(node*2, s, m, i, x);
else update(node*2+1, m+1, e, i, x);
tree[node] = max(tree[node*2], tree[node*2+1]);
}
int Find(int node, int s, int e) {
//cout << s << " " << e << endl;
if(s == e) return s;
if(tree[node*2] > tree[node*2+1]) return Find(node*2, s, (s+e)/2);
else return Find(node*2+1, (s+e)/2+1, e);
}
int main() {
fast;
cin >> n;
for(int i=1; i<=n; i++) {
int s;
cin >> s;
v.eb(s, i);
}
v.eb(-inf, 0);
sort(all(v));
init(1, 0, n);
update(1, 0, n, 0, 0);
int j = 1;
for(int i=1; i<=n; i++) {
dp[i] = -inf;
if(i < v[i].fi) continue;
while(j <= i - v[i].fi) {
update(1, 0, n, j, dp[j]);
j++;
}
int u = Find(1, 0, n);
pre[i] = u;
dp[i] = dp[u] + 1;
}
cout << dp[n] << "\n";
for(int i = n; i; i = pre[i]) {
cout << i - pre[i] << " ";
for(int j = pre[i] + 1; j<=i; j++) {
cout << v[j].se << " ";
}
cout << "\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
640 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
640 KB |
Output is correct |
2 |
Incorrect |
2 ms |
640 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
35 ms |
3256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
44 ms |
3440 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
409 ms |
25596 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
518 ms |
31064 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
454 ms |
29740 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |