Submission #742194

# Submission time Handle Problem Language Result Execution time Memory
742194 2023-05-15T18:20:51 Z sword060 Volontiranje (COCI21_volontiranje) C++17
0 / 110
0 ms 212 KB
#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 time Memory Grader output
1 Incorrect 0 ms 212 KB Subsequence increasing
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Subsequence increasing
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Subsequence increasing
2 Halted 0 ms 0 KB -