#include #include #define rep(i,n) for(int i=0;i vi; typedef vector vl; typedef vector> vvi; typedef vector> vvl; typedef long double ld; const bool debug = false; int T, N; long long Money; vector L; vector S, P, R; vector D; vector> D_est; vector> Z; set grow, waste; int X = 1; long long Score = 0; vector bi = {1, 2, 4, 8, 16}; void out(int type){ if(!debug){ if(type == 1){ cout << 1; rep(i, N) cout << " " << L[i]; cout << "\n"; } if(type == 2){ cout << 2 << " " << X << "\n"; } }else{ if(type == 2){ rep(i, N) P[i] += X; } } } void in(int t){ vector P_before = P; if(debug){ rep(i, N) R[i] += L[i]; rep(i, N){ if(R[i] == 0){ S[i] = 0; }else{ S[i] = min(R[i], (long long)(sqrtl(R[i]) * pow(1.05, P[i]) * D[i] * Z[t][i])); if(S[i] * 10 >= R[i] * 3) P[i]++; if(S[i] * 10 < R[i]) P[i]--; R[i] -= S[i]; Money += 1000 * S[i]; } Score += S[i]; } cout << Money << "\n"; rep(i, N) cout << S[i] << " "; cout << "\n"; rep(i, N) cout << P[i] << " "; cout << "\n"; rep(i, N) cout << R[i] << " "; cout << "\n"; }else{ cin >> Money; rep(i, N) cin >> S[i]; rep(i, N) cin >> P[i]; rep(i, N) cin >> R[i]; } rep(i, N) if(R[i] + S[i] > 0){ if(R[i] + S[i] == 0){ long double tmp = S[i] / sqrtl(R[i] + S[i]) / pow(1.05, P_before[i]); if(tmp < 0.5) tmp = 0.5; if(tmp >= 1.5) tmp = 1.5; D_est[i].push_back((tmp + 1.5) / 2); }else{ long double tmp = (S[i] + 0.5) / sqrtl(R[i] + S[i]) / pow(1.05, P_before[i]); if(tmp < 0.5) tmp = 0.5; if(tmp >= 1.5) tmp = 1.5; D_est[i].push_back(tmp); } } } long double get_ave(int i){ long double ave = 0; for(ld x : D_est[i]) ave += x; ave /= D_est[i].size(); return ave; // if(debug) cout << ave << ' '; } long long solve(int i){ long long ok = 1, ng = 1001001001001; while(ng - ok > 1){ long long mid = (ok + ng) / 2; if(sqrtl(mid) * pow(1.05, P[i]) * get_ave(i) * 0.6 >= 0.3 * mid) ok = mid; else ng = mid; } return ok; } int main() { // 最初の入力 if(debug){ cin >> T >> N; Money = 2000000; }else cin >> T >> N >> Money; L.resize(N); S.resize(N); P.resize(N); R.resize(N); D.resize(N); Z.resize(T, vector(N)); rep(i, N) grow.insert(i); if(debug){ rep(i, N) cin >> D[i]; rep(t, T) rep(i, N) cin >> Z[t][i]; } D_est.resize(N); int start = 20; int end = 40; // インタラクティブ開始 rep(t, T){ rep(i, N) L[i] = 0; if(t < 3){ X = 1; Money -= 500000 * bi[X - 1]; out(2); }else if(t < start){ { set tmp; for(int i : grow){ if(P[i] <= 0) tmp.insert(i); } for(int i : tmp){ grow.erase(i); waste.insert(i); } } for(int i : grow){ L[i] = min(3 - R[i], Money / 500); Money -= 500 * L[i]; } for(int i : waste){ L[i] = (Money / 5) / (500 * waste.size()); Money -= 500 * L[i]; } out(1); }else if(t < end){ { set tmp; for(int i : grow){ if(P[i] <= 9) tmp.insert(i); } for(int i : tmp){ grow.erase(i); waste.insert(i); } } for(int i : grow){ L[i] = min(solve(i), Money / 500); Money -= 500 * L[i]; } out(1); }else{ for(int i : grow){ L[i] = Money / (500 * int(grow.size())); Money -= 500 * L[i]; } out(1); } in(t); } if(debug) cout << Score; return 0; } // CHECK DEBUG FLAG!!!! // CHECK DEBUG FLAG!!!! // CHECK DEBUG FLAG!!!! // CHECK DEBUG FLAG!!!! // CHECK DEBUG FLAG!!!! // CHECK DEBUG FLAG!!!! // CHECK DEBUG FLAG!!!! // CHECK DEBUG FLAG!!!! // CHECK DEBUG FLAG!!!!