Submission #477469

#TimeUsernameProblemLanguageResultExecution timeMemory
477469NeosHolding (COCI20_holding)C++14
22 / 110
25 ms38772 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef unsigned long long ull; typedef pair<ll, ll> ii; typedef vector<int> vi; typedef vector<ll> vll; typedef vector<ii> vii; typedef vector<vi> vvi; typedef vector<vll> vvll; typedef vector<vii> vvii; #define task "test" #define fastIO ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL) #define forw(i, l, r) for( ll i = (l) ; i < (r) ; i++ ) #define forb(i, r, l) for( ll i = (r) ; i >= (l) ; i-- ) #define sz(x) (int)x.size() #define fi first #define se second #define all(x) x.begin(), x.end() #define numBit(x) __builtin_popcount(x) #define lb lower_bound #define ub upper_bound #define ar array #define endl '\n' const int dx[4] = {-1, 0, 1, 0}; const int dy[4] = {0, -1, 0, 1}; const int N = 22; const ll inf = 0x3f3f3f3f; int n, l, r, k; ll a[N]; int dp[N][N][10000]; int solve(int i, int j, int left) { int &ret = dp[i][j][left]; if (ret != -1) return ret; if (i >= j || j > r || i >= l) return 0; if (j - i <= left) ret = solve(i + 1, j + 1, left - (j - i)) + (a[j] - a[i]); ret = max(ret, solve(i + 1, j, left)); ret = max(ret, solve(i, j + 1, left)); ret = max(ret, solve(i + 1, j + 1, left)); return ret; } int main() { // fastIO; scanf("%d %d %d %d", &n, &l, &r, &k); --l, --r; ll sum = 0; memset(dp, -1, sizeof dp); forw(i, 0, n) { scanf("%lld", &a[i]); if (i >= l && i <= r) sum += a[i]; } printf("%lld", sum - solve(0, l, k)); }

Compilation message (stderr)

holding.cpp: In function 'int main()':
holding.cpp:55:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   55 |   scanf("%d %d %d %d", &n, &l, &r, &k);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
holding.cpp:61:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   61 |     scanf("%lld", &a[i]);
      |     ~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...