Submission #238031

#TimeUsernameProblemLanguageResultExecution timeMemory
238031KubinHorses (IOI15_horses)C++11
17 / 100
35 ms16768 KiB
#include <bits/stdc++.h> using namespace std; size_t n; int X[1 << 19], Y[1 << 19], Q[16][1024]; int compute() { for(size_t i = 0; i < 16; i++) for(size_t j = 0; j < 1024; j++) Q[i][j] = INT_MIN/3; Q[0][1] = 0; for(size_t i = 0; i <= n; i++) { for(size_t k = 1024; k --> 0; ) { if(i and k) Q[i][k-1] = max(Q[i][k-1], Q[i][k] + Y[i-1]); if(X[i]*k<1024) Q[i+1][X[i]*k] = max(Q[i+1][X[i]*k], Q[i][k]); } } int r = 0; for(size_t k = 0; k < 1024; k++) r = max(r, Q[n][k]); return r; } int init(int _n, int x[], int y[]) { n = _n; copy(x, x + n, X); copy(y, y + n, Y); return compute(); } int updateX(int pos, int val) { X[pos] = val; return compute(); } int updateY(int pos, int val) { Y[pos] = val; return compute(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...