Submission #1106173

# Submission time Handle Problem Language Result Execution time Memory
1106173 2024-10-29T13:17:09 Z icebear Stove (JOI18_stove) C++17
50 / 100
622 ms 262144 KB
// ~~ icebear ~~
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;

#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORR(i,a,b) for(int i=(a); i>=(b); --i)
#define rep(i, n) for(int i=0; i<(n); ++i)
#define red(i, n) for(int i=(n)-1; i>=0; --i)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define task "icebearat"

const int MOD = 1e9 + 7;
const int inf = 1e9 + 27092008;
const ll LLinf = 1e18 + 27092008;
const int N = 5000 + 5;
int n, k, t[N];
ll dp[N][N];

void solve() {
    cin >> n >> k;
    FOR(i, 1, n) cin >> t[i];
    memset(dp, 0x3f, sizeof dp);
    dp[0][0] = 0;
    FOR(i, 1, n) FOR(j, 1, k)
        dp[i][j] = min(dp[i - 1][j] + (t[i] + 1) - (t[i - 1] + 1), dp[i - 1][j - 1] + 1);
    cout << dp[n][k];
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    if (fopen(task".inp", "r")){
        freopen(task".inp", "r", stdin);
        freopen(task".out", "w", stdout);
    }
    int tc = 1;
//     cin >> tc;
    while(tc--) solve();
    return 0;
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:41:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |         freopen(task".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
stove.cpp:42:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |         freopen(task".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 25 ms 196432 KB Output is correct
2 Correct 31 ms 196432 KB Output is correct
3 Correct 36 ms 196424 KB Output is correct
4 Correct 41 ms 196324 KB Output is correct
5 Correct 37 ms 196424 KB Output is correct
6 Correct 48 ms 196424 KB Output is correct
7 Correct 50 ms 196364 KB Output is correct
8 Correct 55 ms 196440 KB Output is correct
9 Correct 58 ms 196432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 25 ms 196432 KB Output is correct
2 Correct 31 ms 196432 KB Output is correct
3 Correct 36 ms 196424 KB Output is correct
4 Correct 41 ms 196324 KB Output is correct
5 Correct 37 ms 196424 KB Output is correct
6 Correct 48 ms 196424 KB Output is correct
7 Correct 50 ms 196364 KB Output is correct
8 Correct 55 ms 196440 KB Output is correct
9 Correct 58 ms 196432 KB Output is correct
10 Correct 60 ms 196424 KB Output is correct
11 Correct 60 ms 196432 KB Output is correct
12 Correct 59 ms 196432 KB Output is correct
13 Correct 62 ms 196424 KB Output is correct
14 Correct 66 ms 196552 KB Output is correct
15 Correct 64 ms 196424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 25 ms 196432 KB Output is correct
2 Correct 31 ms 196432 KB Output is correct
3 Correct 36 ms 196424 KB Output is correct
4 Correct 41 ms 196324 KB Output is correct
5 Correct 37 ms 196424 KB Output is correct
6 Correct 48 ms 196424 KB Output is correct
7 Correct 50 ms 196364 KB Output is correct
8 Correct 55 ms 196440 KB Output is correct
9 Correct 58 ms 196432 KB Output is correct
10 Correct 60 ms 196424 KB Output is correct
11 Correct 60 ms 196432 KB Output is correct
12 Correct 59 ms 196432 KB Output is correct
13 Correct 62 ms 196424 KB Output is correct
14 Correct 66 ms 196552 KB Output is correct
15 Correct 64 ms 196424 KB Output is correct
16 Runtime error 622 ms 262144 KB Execution killed with signal 9
17 Halted 0 ms 0 KB -