제출 #1337986

#제출 시각아이디문제언어결과실행 시간메모리
1337986JuanJLRastuci (COCI25_rastuci)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define fst first
#define snd second
#define pb push_back
#define mset(a,v) memset(a,v,sizeof(a))
#define forn(i,a,b) for(int i = a; i<b; i++)
#define SZ(x) (int)x.size()
#define ALL(x) x.begin(),x.end()
#define FIN ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;

template <typename T>
using iset = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#ifdef D
	#define debug(x) cout<<x
#else
	#define debug(x) //nothing
#endif

const int MAXN = 5003;

int n;
ll ps[MAXN];

//STree dp[MAXN];
pair<ll,ll> dmax[MAXN][MAXN];

int main(){ FIN;
	cin>>n;

	forn(i,1,n+1) dp[i]=STree(n+2-i,i);
	
	forn(i,1,n+1) cin>>ps[i];
	
	ps[0]=0;
	forn(i,2,n+1) ps[i]+=ps[i-1];


	forn(i,0,n+2) forn(j,0,n+2) dmax[i][j]={-10000000,-1};

	forn(i,1,n+1) dmax[i][n]={1,n};
	int l,r,mid;
	for(int i = n; i>=1; i--){
		for(int j = n-1; j>=i; j--){
			 l = 1;  r=n;
			while(l<=r){
				mid = (l+r)/2;
								//cout<<mid<<" "<<l<<" "<<r<<'\n';
					if(ps[mid]-ps[j]>=ps[j]-ps[i-1]) r=mid-1;
				else l = mid+1;
			}
			if(l<=n) dmax[i][j]={dmax[j+1][l].fst+1,j};
		}
		for(int j = n-1; j>=0; j--){
			dmax[i][j]=max(dmax[i][j],dmax[i][j+1]);
		}
	}
	
	/*
	//cout<<"Update base\n";
	forn(i,1,n+1) dp[i].upd(n,{1,n});

	//cout<<"calculo dp\n";
	int l,r,mid;
	for(int i = n; i>=1; i--){
		for(int j = n-1; j>=i; j--){
			 l = 1;  r=n;
			while(l<=r){
				mid = (l+r)/2;
								//cout<<mid<<" "<<l<<" "<<r<<'\n';

				if(ps[mid]-ps[j]>=ps[j]-ps[i-1]) r=mid-1;
				else l = mid+1;
			}
			if(l<=n) dp[i].upd(j,{dp[j+1].query(l,n+1).fst+1,j});
		}
	}
	*/
	
	/*forn(i,1,n+1){
		forn(j,i,n+1){
						cout<<i<<" "<<j<<": ";cout<<"{"<<dp[i].query(j,j+1).fst<<" "<<dp[i].query(j,j+1).snd<<"}"<<'\n';

		}
	}*/

	cout<<dmax[1][1].fst<<'\n';
	
/*	cout<<dp[1].query(1,n+1).fst<<'\n';

	return 0;
	int L = 1;
	int R = dp[1].query(1,n+1).snd;
	cout<<ps[R]-ps[L-1]<<" ";

	while(R!=n){
		//cout<<L<<" "<<R<<" = ";
		int nL = R+1;
		int nR;

		 l = 1;  r=n;
		while(l<=r){
			mid = (l+r)/2;

			if(ps[mid]-ps[nL-1]>=ps[R]-ps[L-1]) r=mid-1;
			else l = mid+1;
		}
		nR=dp[nL].query(l,n+1).snd;
		
		cout<<ps[nR]-ps[nL-1]<<' ';
		L=nL;
		R=nR;
	}
	cout<<'\n';
	*/	
	
	return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'int main()':
Main.cpp:36:23: error: 'dp' was not declared in this scope; did you mean 'dup'?
   36 |         forn(i,1,n+1) dp[i]=STree(n+2-i,i);
      |                       ^~
      |                       dup
Main.cpp:36:29: error: 'STree' was not declared in this scope
   36 |         forn(i,1,n+1) dp[i]=STree(n+2-i,i);
      |                             ^~~~~