# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
57446 | 2018-07-15T05:03:50 Z | 강태규(#1669) | Teams (CEOI11_tea) | C++11 | 942 ms | 111196 KB |
#include <iostream> #include <algorithm> #include <vector> #include <queue> #include <deque> #include <set> #include <map> #include <unordered_map> #include <functional> #include <cstring> #include <cmath> #include <ctime> #include <cstdlib> using namespace std; typedef long long llong; typedef long double ld; typedef pair<int, int> pii; typedef pair<llong, llong> pll; const int inf = 1e7; int n; pii a[1000001]; int dp[1000001]; int pr[1000001]; int par[1000001][20]; int main() { scanf("%d", &n); for (int i = 1; i <= n; ++i) { int x; scanf("%d", &x); a[i] = pii(x, i); } sort(a + 1, a + (n + 1)); for (int i = 1; i <= n; ++i) { int x = i - a[i].first; if (x < 0) { dp[i] = inf; } else { for (int j = 20; j--; ) { int y = par[x][j]; if (y == 0) continue; int z = par[y][0]; if (max(dp[y], i - y) > max(dp[z], i - z)) x = y; } x = par[x][0]; if (max(dp[x], i - x) > max(dp[i - a[i].first], a[i].first)) x = i - a[i].first; dp[i] = max(dp[x], i - x); pr[i] = x; } par[i][0] = i - 1; while (par[i][0] && dp[i] <= dp[par[i][0]]) par[i][0] = par[par[i][0]][0]; for (int j = 1; j < 20; ++j) par[i][j] = par[par[i][j - 1]][j - 1]; } vector<pii> ans; for (int i = n; i > 0; i = pr[i]) { ans.emplace_back(pr[i], i); } printf("%d\n", (int)ans.size()); for (pii i : ans) { printf("%d", i.second - i.first); for (int j = i.first + 1; j <= i.second; ++j) { printf(" %d", a[j].second); } printf("\n"); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 288 KB | Output is correct |
2 | Correct | 2 ms | 416 KB | Output is correct |
3 | Correct | 2 ms | 432 KB | Output is correct |
4 | Correct | 2 ms | 432 KB | Output is correct |
5 | Correct | 2 ms | 608 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 608 KB | Output is correct |
2 | Correct | 0 ms | 608 KB | Output is correct |
3 | Correct | 2 ms | 608 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 7 ms | 608 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 1072 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 1104 KB | Output is correct |
2 | Correct | 6 ms | 1104 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 58 ms | 8544 KB | Output is correct |
2 | Correct | 45 ms | 8544 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 71 ms | 9508 KB | Output is correct |
2 | Correct | 58 ms | 9508 KB | Output is correct |
3 | Correct | 57 ms | 9508 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 642 ms | 76048 KB | Output is correct |
2 | Correct | 427 ms | 76416 KB | Output is correct |
3 | Correct | 508 ms | 76416 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 756 ms | 100884 KB | Output is correct |
2 | Correct | 536 ms | 111196 KB | Output is correct |
3 | Correct | 526 ms | 111196 KB | Output is correct |
4 | Correct | 760 ms | 111196 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 752 ms | 111196 KB | Output is correct |
2 | Correct | 468 ms | 111196 KB | Output is correct |
3 | Correct | 576 ms | 111196 KB | Output is correct |
4 | Correct | 942 ms | 111196 KB | Output is correct |