#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>*/
#define pb push_back
#define mp make_pair
#define sz(s) ((int)(s.size()))
#define all(s) s.begin(), s.end()
#define rep(i, a, n) for (int i = a; i <= n; ++i)
#define per(i, n, a) for (int i = n; i >= a; --i)
#define onlycin ios_base::sync_with_stdio(false); cin.tie(0)
#define F first
#define S second
using namespace std;
// using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;
/*typedef tree<
pair < int, int >,
null_type,
less< pair < int, int > >,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;*/
// find_by_order() order_of_key()
const int MAXN = (int)5e5+228;
const char nxtl = '\n';
const int mod = (int)1e9+7;
const double eps = (double)1e-7;
template<typename T> inline bool updmin(T &a, const T &b) {return a > b ? a = b, 1 : 0;}
template<typename T> inline bool updmax(T &a, const T &b) {return a < b ? a = b, 1 : 0;}
int n, l, r, a[MAXN];
pair < ll, ll > dp[2002][2020];
inline pair < ll, ll > Merge(pair < ll, ll > x, ll sum) {
updmax(x.F, sum);
x.S |= sum;
return x;
}
int main() {
#ifdef accepted
freopen(".in", "r", stdin);
freopen(".out", "w", stdout);
#endif
onlycin;
cin >> n >> l >> r;
rep(i, 1, n) cin >> a[i];
rep(i, 0, n) rep(j, 0, n) dp[i][j] = mp((ll)1e15, (ll)1e15);
dp[0][0] = mp(0ll, 0ll);
rep(i, 1, n) {
rep(k, 1, r) {
dp[i][k] = mp((ll)1e15, (ll)1e15);
ll cur = 0ll;
per(j, i, 1) {
cur += a[j];
updmin(dp[i][k], Merge(dp[j-1][k-1], cur));
}
// cerr << i << ' '<< k << ' '<< dp[i][k].F << ' '<< dp[i][k].S << nxtl;
}
}
ll res = LLONG_MAX;
rep(i, l, r) updmin(res, dp[n][i].S);
cout << res << nxtl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
1 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
424 KB |
Output is correct |
2 |
Incorrect |
1 ms |
424 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
424 KB |
Output is correct |
2 |
Incorrect |
2 ms |
444 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
476 KB |
Output is correct |
2 |
Incorrect |
1 ms |
528 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
548 KB |
Output is correct |
2 |
Incorrect |
1 ms |
548 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |