# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
533879 |
2022-03-07T14:27:11 Z |
CaroLinda |
Teams (CEOI11_tea) |
C++14 |
|
323 ms |
94124 KB |
#include <bits/stdc++.h>
#define mk make_pair
#define lp(i,a,b) for(int i = a ; i < b; i++ )
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
const int MAX = 1e6+5 ;
using namespace std ;
int main(){
ios_base::sync_with_stdio(false );
cin.tie(0) ;
int N ;
cin >> N ;
vector<int> arr(N) , idx(N) ; iota(all(idx) , 0) ;
vector<int> corte(N) , mx(N) , tam(N) ;
for(auto &e : arr ) cin >> e ;
sort(all(idx),[&](int a, int b) { return arr[a] > arr[b] ; }) ;
vector<int> dp(N) ;
vector< vector<int> > sweep( N+1 , vector<int>() ) ;
for(int i = 0 ; i < N ; i++ ){
if(arr[idx[i]]+i <= N) sweep[arr[idx[i]]+i].push_back(i) ;
dp[i] = -2*N ;
corte[i] = -1 ;
if(i+1 >= arr[idx[0]]) dp[i] = 1 , tam[i] = i+1 ;
for(auto e : sweep[i+1]){
if(e == 0) continue ;
if( i-e+1 >= arr[idx[e]] && mk(dp[e-1]+1,-max(tam[e-1], i-e+1) ) > mk(dp[i] , -tam[i]) ){
corte[i] = e-1 ;
dp[i] = dp[e-1]+1 ;
tam[i] = max(tam[e-1] , i-e+1 ) ;
}
}
if(i && dp[i-1] > 0 ){
int p = i/dp[i-1] ;
if( tam[i-1] > p || tam[i-1]*dp[i-1] > i ){
if(mk(dp[i-1], -tam[i-1]) > mk(dp[i] , -tam[i]) ){
dp[i] = dp[i-1] ;
tam[i] = tam[i-1] ;
}
}
else if( mk(dp[i-1], -tam[i-1]-1) > mk(dp[i] , -tam[i]) ){
dp[i] = dp[i-1] ;
tam[i] = tam[i-1]+1 ;
}
}
//cout << dp[i] << " " << tam[i] << endl ;
}
vector<vector<int> > ans ;
int x = N-1 ;
while(x != -1){
ans.push_back(vector<int>()) ;
int i ;
for(i = x-arr[idx[x]] ; i >= x-tam[x] ; i-- ){
if(dp[i] == dp[x]-1 && tam[i] <= tam[x] ) break ;
}
for(int j = i+1 ; j<= x ;j++ ) ans.back().push_back(idx[j]+1) ;
x = i ;
}
cout << sz(ans) <<"\n" ;
for(auto e : ans ){
cout << sz(e) <<" " ;
for(auto ee : e ) cout << ee <<" " ;
cout << "\n" ;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
1 ms |
316 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
716 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
716 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
6836 KB |
Output is correct |
2 |
Incorrect |
24 ms |
7748 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
7976 KB |
Output is correct |
2 |
Incorrect |
22 ms |
7484 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
228 ms |
67404 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
323 ms |
86988 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
307 ms |
75784 KB |
Output is correct |
2 |
Correct |
224 ms |
70028 KB |
Output is correct |
3 |
Incorrect |
295 ms |
94124 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |