#include using namespace std; const int INF=1e9; using pii=pair; using tii=tuple; #define rep(i,n) for (int i=0;i<(int)(n);i++) #define all(v) v.begin(),v.end() template void chmin(T &a,T b){ if(a>b){ a=b; } } template void chmax(T &a,T b){ if(a h,p,x; void input_cin(){ cin >> n; if(n==-1) exit(0); h.assign(n,0); p.assign(n,0); x.assign(n,0); rep(i,n) cin >> h[i] >> p[i] >> x[i]; } }Input; struct solver{ struct shooter{ int j; int l; int s; }; struct enemy{ int fh; int h; int p; }; void solve(){ int score=0; shooter me={12,1,0}; vector> grid(H,vector(W,{0,0,0})); int to=-1; string root; rep(t,1000){ for(int i=H-2;0<=i;i--){ rep(j,W){ grid[i+1][j]=grid[i][j]; grid[i][j]={0,0,0}; } } Input.input_cin(); rep(i,Input.n){ grid[0][Input.x[i]].fh=Input.h[i]; grid[0][Input.x[i]].h=Input.h[i]; grid[0][Input.x[i]].p=Input.p[i]; } if(to==-1){ double mx=0; int p=-1; string mx_root; rep(i,H){ rep(j,W){ if(0> dp(n+1,vector(z+1,{-1,-1})); dp[0][0]={-2,-2}; rep(ii,n){ rep(jj,z+1){ if(dp[ii][jj]==pair({-1,-1})) continue; dp[ii+1][jj]={ii,jj}; if(z({-1,-1})){ t=ii; pa={ii,z}; break; } } if(t==-1||0({0,0})){ pii new_pa=dp[pa.first][pa.second]; if(new_pa.second!=pa.second){ if(me.j> p; } Solver.solve(); }