// TLEの原因探し中... #include using namespace std; #define SET_A( A , N ) FOR( VARIABLE_FOR_CIN_A , 0 , N ){ cin >> A[VARIABLE_FOR_CIN_A]; } #define FOR( VAR , INITIAL , FINAL_PLUS_ONE ) for( int VAR = INITIAL ; VAR < FINAL_PLUS_ONE ; VAR ++ ) #define REPEAT( HOW_MANY_TIMES ) FOR( VARIABLE_FOR_REPEAT_ ## HOW_MANY_TIMES , 0 , HOW_MANY_TIMES ) #define COUT_A( A , N ) FOR( VARIABLE_FOR_OUTPUT_ARRAY , 0 , N ){ cout << A[VARIABLE_FOR_OUTPUT_ARRAY] << (VARIABLE_FOR_OUTPUT_ARRAY==N-1?"":" "); } cout << endl int main() { int T , N , M; cin >> T >> N >> M; M /= 500; int R[N] = {}; int P[N] = {}; REPEAT( T ){ int temp = 0; FOR( i , 0 , N ){ temp = max( temp , R[i] ); } int L[N] = {}; FOR( i , 0 , N ){ if( temp - R[i] <= M ){ M -= L[i] = temp - R[i]; } } if( M > 0 ){ temp = 0; FOR( i , 0 , N ){ temp += P[i] = 1 << P[i]; } temp = M / temp; FOR( i , 0 , N ){ L[i] += temp * P[i]; } } cout << 1 << " "; COUT_A( L , N ); cin >> M; M /= 500; SET_A( P , N ); SET_A( P , N ); SET_A( R , N ); } return 0; }