# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
57815 |
2018-07-16T09:17:49 Z |
ainta(#1666) |
Teams (CEOI11_tea) |
C++11 |
|
624 ms |
26564 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;
}
void Print(int b, int e) {
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;
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--;
}
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:46:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &n);
~~~~~^~~~~~~~~~
tea.cpp:48: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:69:5: warning: 'res' may be used uninitialized in this function [-Wmaybe-uninitialized]
Get(res);
~~~^~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
3 ms |
448 KB |
Integer parameter [name=s_i] equals to 21, violates the range [1, 20] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
448 KB |
Output is correct |
2 |
Incorrect |
2 ms |
612 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
612 KB |
Integer parameter [name=s_i] equals to 201, violates the range [1, 200] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
612 KB |
Integer parameter [name=s_i] equals to 5000, violates the range [1, 4999] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
700 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
42 ms |
2924 KB |
Integer parameter [name=s_i] equals to 80006, violates the range [1, 80005] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
38 ms |
3516 KB |
Integer parameter [name=s_i] equals to 90004, violates the range [1, 90003] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
394 ms |
20300 KB |
Integer parameter [name=s_i] equals to 750014, violates the range [1, 750013] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
624 ms |
26564 KB |
Integer parameter [name=s_i] equals to 1000001, violates the range [1, 1000000] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
420 ms |
26564 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |