# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
65415 |
2018-08-07T14:22:38 Z |
Googal |
Teams (CEOI11_tea) |
C++14 |
|
637 ms |
90800 KB |
#include <algorithm>
#include <iostream>
#include <memory.h>
#include <bitset>
using namespace std;
const int NMAX = 1e6 + 1e2;
const int INF = 1e9;
int n;
int dp[NMAX];
int pr[NMAX], opt[NMAX], par[NMAX];
pair < int, int > a[NMAX];
bitset < NMAX > ok;
bool check(int x) {
ok = 0;
ok[0] = 1;
for(int i = 1; i <= n; i++) {
if(i - a[i].first < 0) {
dp[i] = -INF;
} else {
dp[i] = pr[i - a[i].first] + 1;
if(opt[i - a[i].first] >= i - x) {
ok[i] = 1;
par[i] = opt[i - a[i].first];
}
}
pr[i] = pr[i - 1];
opt[i] = opt[i - 1];
if(ok[i] == 1 && pr[i] <= dp[i]) {
opt[i] = i;
pr[i] = dp[i];
}
}
return (bool)ok[n];
}
void printsol(int x) {
if(x == 0)
return;
int p1 = par[x];
printsol(p1);
cout << x - p1 << ' ';
for(int i = p1 + 1; i <= x; i++)
cout << a[i].second << ' ';
cout << '\n';
}
void bin_src(int &le, int &ri) {
while(le != ri) {
int mid = (le + ri) / 2;
if(check(mid) == false)
le = mid + 1;
else
ri = mid;
}
}
int main()
{
ios::sync_with_stdio(false);
cin >> n;
for(int i = 1; i <= n; i++) {
cin >> a[i].first;
a[i].second = i;
}
sort(a + 1, a + n + 1);
int le = 1;
int ri = n;
bin_src(le, ri);
check(le);
cout << dp[n] << '\n';
printsol(n);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
504 KB |
Output is correct |
2 |
Correct |
3 ms |
688 KB |
Output is correct |
3 |
Correct |
3 ms |
688 KB |
Output is correct |
4 |
Correct |
2 ms |
764 KB |
Output is correct |
5 |
Correct |
2 ms |
764 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
764 KB |
Output is correct |
2 |
Correct |
3 ms |
764 KB |
Output is correct |
3 |
Correct |
3 ms |
808 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
944 KB |
Output is correct |
2 |
Correct |
3 ms |
944 KB |
Output is correct |
3 |
Correct |
2 ms |
944 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
972 KB |
Output is correct |
2 |
Correct |
5 ms |
972 KB |
Output is correct |
3 |
Correct |
6 ms |
1008 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
1040 KB |
Output is correct |
2 |
Correct |
7 ms |
1112 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
36 ms |
3256 KB |
Output is correct |
2 |
Correct |
34 ms |
3512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
40 ms |
3748 KB |
Output is correct |
2 |
Correct |
33 ms |
3752 KB |
Output is correct |
3 |
Correct |
42 ms |
4484 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
317 ms |
24500 KB |
Output is correct |
2 |
Correct |
331 ms |
27776 KB |
Output is correct |
3 |
Correct |
373 ms |
30868 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
424 ms |
38516 KB |
Output is correct |
2 |
Correct |
626 ms |
90800 KB |
Output is correct |
3 |
Correct |
464 ms |
90800 KB |
Output is correct |
4 |
Correct |
466 ms |
90800 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
500 ms |
90800 KB |
Output is correct |
2 |
Correct |
416 ms |
90800 KB |
Output is correct |
3 |
Correct |
450 ms |
90800 KB |
Output is correct |
4 |
Correct |
637 ms |
90800 KB |
Output is correct |