Submission #911491

# Submission time Handle Problem Language Result Execution time Memory
911491 2024-01-19T02:04:52 Z MilosMilutinovic Teams (CEOI11_tea) C++14
50 / 100
2500 ms 22808 KB
#include<bits/stdc++.h>
 
#define pb push_back
#define fi first
#define se second
#define mp make_pair
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
 
template <typename T> bool chkmin(T &x,T y){return x>y?x=y,1:0;}
template <typename T> bool chkmax(T &x,T y){return x<y?x=y,1:0;}
 
ll readint(){
	ll x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

int n,dp[1000005],prv[1000005];
pii a[1000005];

int solve(int x){
	for(int i=0;i<=n;i++){
		dp[i]=(int)-1e9;
		prv[i]=0;
	}
	dp[0]=0;
	for(int i=1;i<=n;i++){
		if(a[i].fi>i) continue;
		for(int j=max(0,i-x);j<=i-a[i].fi;j++){
			if(dp[j]+1>dp[i]) dp[i]=dp[j]+1,prv[i]=j;
		}
	}
	return dp[n];
}

int main(){
	n=readint();
	for(int i=1;i<=n;i++) a[i].fi=readint(),a[i].se=i;
	sort(a+1,a+n+1);
	int mx=solve(n);
	int l=a[n].fi,r=n,f=n;
	while(l<=r){
		int mid=(l+r)/2;
		if(solve(mid)==mx) f=mid,r=mid-1;
		else l=mid+1;
	}
	solve(f);
	printf("%d\n",mx);
	int p=n;
	while(p>0){
		printf("%d ",p-prv[p]);
		for(int i=prv[p]+1;i<=p;i++) printf("%d ",a[i].se);
		printf("\n");
		p=prv[p];
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4440 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 4608 KB Output is correct
2 Correct 28 ms 4444 KB Output is correct
3 Correct 35 ms 4592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 4604 KB Output is correct
2 Correct 21 ms 4608 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2541 ms 7004 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2542 ms 7260 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2567 ms 18604 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2514 ms 21844 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2589 ms 22808 KB Time limit exceeded
2 Halted 0 ms 0 KB -