# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
57825 |
2018-07-16T09:39:02 Z |
ainta(#1666) |
Teams (CEOI11_tea) |
C++11 |
|
624 ms |
37732 KB |
#include<cstdio>
#include<algorithm>
using namespace std;
int n;
struct point {
int x, num;
bool operator <(const point &p)const {
return x > p.x;
}
}w[1010000];
int Deq[1010000], head, tail, P[1010000], U[1010000], BB[1010000], EE[1010000];
int Get(int M) {
int i, r = 0, res = 0;
head = 1, tail = 0;
int b = 1, e = 1;
Deq[++tail] = 1;
while (1) {
BB[r] = b, EE[r] = e, U[r] = Deq[head];
int b2, e2;
e2 = min(n + 1, e + M);
if (head > tail)break;
b2 = P[Deq[head]];
if (b2 > e2)break;
r++;
if (e2 == n + 1) {
res = r;
}
while (e < e2) {
e++;
if (e == n + 1)continue;
while (head <= tail && P[Deq[tail]] >= P[e])tail--;
Deq[++tail] = e;
}
while (head <= tail && Deq[head] < b2)head++;
b = b2;
}
return res;
}
int rr;
void Print(int b, int e) {
if (b >= e || e-b > rr) {
while (1) {}
}
printf("%d ", e - b);
for (int i = b; i < e; i++)printf("%d ", w[i].num);
puts("");
}
int main() {
int i;
scanf("%d", &n);
for (i = 1; i <= n; i++) {
scanf("%d", &w[i].x);
w[i].num = i;
}
sort(w + 1, w + n + 1);
for (i = 1; i <= n; i++)P[i] = i + w[i].x;
int pv = 0, cnt = 0;
while (1) {
cnt++;
pv += w[pv + 1].x;
if (pv > n)cnt--;
if (pv >= n)break;
}
int b = w[1].x, e = n, mid, res;
while (b <= e) {
mid = (b + e) >> 1;
if (Get(mid) == cnt) {
res = mid;
e = mid - 1;
}
else b = mid + 1;
}
Get(res);
printf("%d\n", cnt);
pv = n + 1;
int cur = cnt;
rr = res;
while (cur) {
if (pv - res >= BB[cur - 1]) {
Print(pv - res, pv);
pv -= res;
}
else {
Print(U[cur - 1], pv);
pv = U[cur - 1];
}
cur--;
}
if (pv != 1) {
while (1) {}
}
return 0;
}
Compilation message
tea.cpp: In function 'int Get(int)':
tea.cpp:13:6: warning: unused variable 'i' [-Wunused-variable]
int i, r = 0, res = 0;
^
tea.cpp: In function 'int main()':
tea.cpp:50:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &n);
~~~~~^~~~~~~~~~
tea.cpp:52:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &w[i].x);
~~~~~^~~~~~~~~~~~~~~
tea.cpp:73:5: warning: 'res' may be used uninitialized in this function [-Wmaybe-uninitialized]
Get(res);
~~~^~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
448 KB |
Output is correct |
3 |
Correct |
3 ms |
448 KB |
Output is correct |
4 |
Correct |
2 ms |
448 KB |
Output is correct |
5 |
Correct |
2 ms |
572 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
572 KB |
Output is correct |
2 |
Incorrect |
2 ms |
652 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
652 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
652 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
676 KB |
Output is correct |
2 |
Correct |
4 ms |
700 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
50 ms |
2300 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
2556 KB |
Output is correct |
2 |
Correct |
29 ms |
2556 KB |
Output is correct |
3 |
Correct |
46 ms |
2716 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
308 ms |
17428 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
468 ms |
23004 KB |
Output is correct |
2 |
Correct |
624 ms |
37732 KB |
Output is correct |
3 |
Incorrect |
368 ms |
37732 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
374 ms |
37732 KB |
Output is correct |
2 |
Correct |
342 ms |
37732 KB |
Output is correct |
3 |
Incorrect |
413 ms |
37732 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |