Dp Solution Codeforces Round #260 (Div. 2) C. Boredom,
# Include <iostream> # include <map> # include <string> # include <cstring> # include <cstdio> # include <cstdlib> # include <cmath> # include <queue> # include <vector> # include <algorithm> using namespace std; long shu [100010], fu [100010]; int main () {int t, n, I, r =-1, l = 100010; cin> n; for (I = 0; I <n; I ++) {cin> t; shu [t] ++; l = min (l, t ); r = max (r, t);} fu [1] = 1 * shu [1]; for (I = max (l, 2); I <= r; I ++) fu [I] = max (fu [I-1], fu [I-2] + shu [I] * I); // front I count (including I) the maximum score is equal to the maximum score obtained by the number of I-1, and the maximum cout value obtained by selecting the number of I. // The maximum cout value of the two cout <fu [r];}
How can codeforces view the test data after the competition ends?
Click standing and double-click the person passing through the standing. The AC is the AC code.
What is codeforces?
.. Thank you!