# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
57460 |
2018-07-15T05:49:00 Z |
윤교준(#1672) |
Teams (CEOI11_tea) |
C++11 |
|
2500 ms |
203572 KB |
#include <bits/stdc++.h>
#define rf(x) (x)=0;while(*p<48)p++;while(47<*p)(x)=((x)<<3)+((x)<<1)+(*p++&15);
//#define rf(x) (x)=0;while(*p<48)im=*p=='-';while(47<*p)(x)=((x)<<3)+((x)<<1)+(*p++&15);if(im)(x)=-(x);
#define pb push_back
#define eb emplace_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define befv(V) ((V)[(sz(V)-2)])
#define sorv(V) sort(allv(V))
#define revv(V) reverse(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define clv(V) (V).clear()
#define upmin(a,b) (a)=min((a),(b))
#define upmax(a,b) (a)=max((a),(b))
#define rb(x) ((x)&(-(x)))
#define cb(x) (x)=(!(x))
#define INF (0x3f3f3f3f)
#define INFLL (0x3f3f3f3f3f3f3f3fll)
#define INFST (0x7f7f7f7f)
#define INFLLST (0x7f7f7f7f7f7f7f7fll)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
typedef complex<ld> base;
const ld EPS = (ld)1e-7;
const ld PI = acos(0) * 2;
bool isZero(const ld& x) { return abs(x) <= EPS; }
int sign(const ld& x) { return isZero(x) ? 0 : (0 < x ? 1 : -1); }
ll gcd(ll a, ll b) { for(;b;a%=b,swap(a,b)){} return abs(a); }
pll operator + (const pll& a, const pll& b) { return pll(a.first+b.first, a.second+b.second); }
pll operator - (const pll& a, const pll& b) { return pll(a.first-b.first, a.second-b.second); }
pll operator * (const pll& a, const ll& b) { return pll(a.first*b, a.second*b); }
ll operator * (const pll& a, const pll& b) { return a.first*b.second - b.first*a.second; }
ll ccw(const pll& a, const pll& b, const pll& c) { return a*b + b*c + c*a; }
void fg(vector<int> G[], int a, int b) { G[a].pb(b); G[b].pb(a); }
void fg(vector<pii> G[], int a, int b, int c) { G[a].pb({b, c}); G[b].pb({a, c}); }
const int MAXN = 1000005;
const int MX = 2097152;
struct SEG {
multiset<int> pd[MX];
int d[MX*2];
void init() {
for(int i = 0; i < MX; i++) pd[i].clear();
fill(d, d+MX*2, -INF);
}
void insert(int x, int r) {
pd[x].insert(-r);
d[x+MX] = -(*pd[x].begin());
for(x = (x+MX)>>1; x; x >>= 1)
d[x] = max(d[x<<1], d[x<<1 | 1]);
}
void remove(int x, int r) {
pd[x].erase(pd[x].find(-r));
d[x+MX] = pd[x].empty() ? -INF : -(*pd[x].begin());
for(x = (x+MX)>>1; x; x >>= 1)
d[x] = max(d[x<<1], d[x<<1 | 1]);
}
int get(int s, int e) {
int r = -INF; for(s += MX, e += MX; s <= e; s >>= 1, e >>= 1) {
if(s&1) upmax(r, d[s++]); if(~e&1) upmax(r, d[e--]);
} return r;
}
} seg;
int dp[MAXN];
vector<int> BV[MAXN];
int A[MAXN], B[MAXN];
int N, AnsC, AnsL;
int f(int L) {
seg.init();
dp[0] = 0; seg.insert(A[1], 1);
for(int i = 1, j; i <= N; i++) {
j = i-L-1; if(0 <= j) {
seg.remove(j + A[j+1], dp[j]+1);
}
dp[i] = seg.get(0, i);
seg.insert(i + A[i+1], dp[i]+1);
}
return dp[N];
}
int getAns() {
int s = 1, e = N; for(int m; s < e;) {
m = (s+e) >> 1;
if(f(m) < AnsC) s = m+1;
else e = m;
}
return s;
}
int main() {
ios::sync_with_stdio(false);
cin >> N;
for(int i = 1; i <= N; i++) {
cin >> A[i];
B[i] = A[i];
}
sort(A+1, A+N+1); reverse(A+1, A+N+1);
for(int i = 1; i <= N; i++)
BV[B[i]].eb(i);
AnsC = f(INF);
AnsL = getAns();
f(AnsL);
printf("%d\n", AnsC);
for(int i = N, j; i;) {
for(j = i-1; 1 <= j && dp[j] != dp[i]-1; j--);
printf("%d ", i-j);
for(int k = j+1, v; k <= i; k++) {
v = A[k];
printf("%d ", BV[v].back());
BV[v].pop_back();
}
puts("");
i = j;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
175 ms |
138744 KB |
Output is correct |
2 |
Incorrect |
268 ms |
138808 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
291 ms |
138932 KB |
Output is correct |
2 |
Incorrect |
366 ms |
138936 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
345 ms |
138956 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
499 ms |
139208 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
447 ms |
139516 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1099 ms |
144636 KB |
Output is correct |
2 |
Incorrect |
966 ms |
144636 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1222 ms |
145384 KB |
Output is correct |
2 |
Incorrect |
1002 ms |
145384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2523 ms |
187432 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2573 ms |
203552 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2572 ms |
203572 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |