Submission #742194

#TimeUsernameProblemLanguageResultExecution timeMemory
742194sword060Volontiranje (COCI21_volontiranje)C++17
0 / 110
0 ms212 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1005; int x,a[N],dp[N]; bool vis[N]; int main(){ ios::sync_with_stdio(0);cin.tie(0); cin>>x; for(int i=1;i<=x;i++)cin>>a[i]; vector<vector<int>>v; int mx=-1; for(int p=1;p<=x;p++){ int cur=0; for(int j=1;j<=x;j++){ if(vis[j])continue; dp[j]=1; for(int i=1;i<j;i++){ if(vis[i])continue; if(a[i]<a[j]) dp[j]=max(dp[i]+1,dp[j]); } cur=max(cur,dp[j]); } if(mx>cur)break; mx=cur; vector<int>nw; for(int i=x;i>=1;i--){ if(!vis[i]&&dp[i]==cur){ cur--; nw.push_back(a[i]); vis[i]=1; } } reverse(nw.begin(),nw.end()); v.push_back(nw); } cout<<v.size()<<" "<<mx<<"\n"; for(auto i:v){ for(auto j:i) cout<<j<<" "; cout<<"\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...