# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
65403 |
2018-08-07T14:10:33 Z |
Googal |
Teams (CEOI11_tea) |
C++14 |
|
549 ms |
49164 KB |
#include <algorithm>
#include <iostream>
#include <memory.h>
using namespace std;
typedef long long ll;
typedef long double lld;
const int NMAX = 1e6 + 1e2;
const int INF = 1e9;
int n;
int ok[NMAX];
int dp[NMAX];
int pr[NMAX];
int opt[NMAX];
int par[NMAX];
pair < int, int > a[NMAX];
bool check(int x) {
memset(ok, 0, sizeof(ok));
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] && pr[i] <= dp[i]) {
opt[i] = i;
pr[i] = dp[i];
}
}
return (bool)ok[n];
}
void backtrack(int x) {
if(x == 0)
return;
int p1 = par[x];
backtrack(p1);
cout << x - p1 << ' ';
for(int i = p1 + 1; i <= x; i++)
cout << a[i].second << ' ';
cout << '\n';
}
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;
while(le != ri) {
int mid = (le + ri) / 2;
if(check(mid) == false)
le = mid + 1;
else
ri = mid;
}
check(le);
cout << dp[n] << '\n';
backtrack(n);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
4344 KB |
Integer 0 violates the range [1, 1] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
4344 KB |
Integer 0 violates the range [1, 100] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
4388 KB |
Integer 0 violates the range [1, 200] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
4608 KB |
Integer 0 violates the range [1, 4999] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
4780 KB |
Integer 0 violates the range [1, 5000] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
44 ms |
7360 KB |
Integer 0 violates the range [1, 80005] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
44 ms |
8184 KB |
Integer 0 violates the range [1, 90003] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
358 ms |
31928 KB |
Integer 0 violates the range [1, 750013] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
549 ms |
45260 KB |
Integer 0 violates the range [1, 1000000] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
489 ms |
49164 KB |
Integer 0 violates the range [1, 1000000] |
2 |
Halted |
0 ms |
0 KB |
- |