Submission #486966

# Submission time Handle Problem Language Result Execution time Memory
486966 2021-11-13T15:11:11 Z Neos Holding (COCI20_holding) C++14
0 / 110
0 ms 204 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
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 "holding"
#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 numBit(x) (__builtin_popcountll(1ll * (x)))
#define getBit(x, i) ((x) >> (i) & 1)
#define sz(x) (int)x.size()
#define mp make_pair
#define fi first
#define se second
#define ar array
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define debug(x) cerr << #x << " = " << x << '\n';

const int N = 101;
const int M = 2502;

int n, l, r, k, a[N];
int dp[N][N][M];

int DP(int pos, int _at, int k) {
    if (_at > r) return (k < 0 ? 1e9 : 0);
    if (pos > n || k < 0) return 1e9;
    if (dp[pos][_at][k]) return dp[pos][_at][k];

    int cost = abs(pos - _at);

    int mn = DP(pos + 1, _at, k);
    if (k >= cost) mn = min(mn, DP(pos + 1, _at + 1, k - cost) + a[pos]);
    return dp[pos][_at][k] = mn;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen(task".inp", "r", stdin);
    freopen(task".out", "w", stdout);
#endif
//    fastIO;
    scanf("%d %d %d %d", &n, &l, &r, &k); k = min(k, M);
    forw(i, 1, n + 1) scanf("%d", &a[i]);
    printf("%d", DP(1, l, k));
}

Compilation message

holding.cpp: In function 'int main()':
holding.cpp:54:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   54 |     freopen(task".inp", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
holding.cpp:55:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   55 |     freopen(task".out", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
holding.cpp:58:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   58 |     scanf("%d %d %d %d", &n, &l, &r, &k); k = min(k, M);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
holding.cpp:59:28: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   59 |     forw(i, 1, n + 1) scanf("%d", &a[i]);
      |                       ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -