# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
115552 | 2019-06-08T06:48:37 Z | gs14004 | Teams (CEOI11_tea) | C++17 | 560 ms | 70788 KB |
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <assert.h> #include <limits.h> #include <math.h> #include <time.h> #include <iostream> #include <functional> #include <numeric> #include <algorithm> #include <stack> #include <queue> #include <deque> #include <vector> #include <string> #include <bitset> #include <map> #include <set> using namespace std; typedef long long lint; typedef long double llf; typedef pair<int, int> pi; int n; pi a[1000005]; int dp[1000005], ok[1000005], pref[1000005], opt[1000005], par[1000005]; int getans(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] = -1e9; } else{ dp[i] = pref[i - a[i].first] + 1; if(opt[i - a[i].first] >= i - x) ok[i] = 1, par[i] = opt[i - a[i].first]; } pref[i] = pref[i-1]; opt[i] = opt[i-1]; if(ok[i] && pref[i] <= dp[i]){ opt[i] = i; pref[i] = dp[i]; } } return ok[n]; } void track(int x){ if(x == 0) return; int p = par[x]; track(p); printf("%d ",x - p); for(int j=p+1; j<=x; j++){ printf("%d ",a[j].second); } puts(""); } int main(){ cin >> n; for(int i=1; i<=n; i++){ scanf("%d",&a[i].first); a[i].second = i; } sort(a+1, a+n+1); int s = 1, e = n; while(s != e){ int m = (s+e)/2; if(getans(m)) e = m; else s = m+1; } getans(s); printf("%d\n",dp[n]); track(n); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 4224 KB | Output is correct |
2 | Correct | 6 ms | 4352 KB | Output is correct |
3 | Correct | 6 ms | 4352 KB | Output is correct |
4 | Correct | 6 ms | 4212 KB | Output is correct |
5 | Correct | 12 ms | 4352 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 4224 KB | Output is correct |
2 | Correct | 7 ms | 4224 KB | Output is correct |
3 | Correct | 7 ms | 4480 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 4224 KB | Output is correct |
2 | Correct | 7 ms | 4352 KB | Output is correct |
3 | Correct | 7 ms | 4216 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 4480 KB | Output is correct |
2 | Correct | 9 ms | 4480 KB | Output is correct |
3 | Correct | 9 ms | 4452 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 4608 KB | Output is correct |
2 | Correct | 10 ms | 4480 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 34 ms | 7072 KB | Output is correct |
2 | Correct | 36 ms | 6904 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 38 ms | 7396 KB | Output is correct |
2 | Correct | 32 ms | 6800 KB | Output is correct |
3 | Correct | 40 ms | 7416 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 306 ms | 30584 KB | Output is correct |
2 | Correct | 298 ms | 29816 KB | Output is correct |
3 | Correct | 313 ms | 31096 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 560 ms | 40088 KB | Output is correct |
2 | Correct | 429 ms | 70788 KB | Output is correct |
3 | Correct | 446 ms | 37880 KB | Output is correct |
4 | Correct | 385 ms | 35752 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 369 ms | 38136 KB | Output is correct |
2 | Correct | 279 ms | 38444 KB | Output is correct |
3 | Correct | 376 ms | 38392 KB | Output is correct |
4 | Correct | 415 ms | 40128 KB | Output is correct |