답안 #329812

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
329812 2020-11-22T15:53:40 Z Vladth11 Stove (JOI18_stove) C++14
0 / 100
1 ms 364 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define debug(x) cerr << #x << " " << x << "\n"
#define debug_with_space(x) cerr << #x << " " << x << " "

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair <ll, ll> pii;
typedef pair <ll, pii> piii;

const ll NMAX = 100001;
const ll INF = (1 << 16) - 1;
const ll MOD = 1000000007;
const ll BLOCK = 101;
const ll nr_of_bits = 20;

ll dp[2][NMAX];

int main() {
    //ifstream cin("multigraph.in");
    //ofstream cout("multigraph.out");
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n, i, j, last = 0, maxim = (1LL << 60), k;
    cin >> n >> k;
    for(i = 0; i <= k; i++)
        dp[0][i] = dp[1][i] = 2e9;
    for(i = 1; i <= n; i++){
        ll x;
        cin >> x;
        if(i == 1){
            dp[1][1] = 1;
        }else{
            for(j = 1; j <= k; j++){
                dp[i % 2][j] = dp[(i - 1) % 2][j] + (x - last);
                dp[i % 2][j] = min(dp[(i - 1) % 2][j - 1] + 1, dp[i % 2][j]);
                if(i == n)
                maxim = min(maxim, dp[i % 2][j]);
            }
        }
        last = x;
    }
    cout << maxim;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Incorrect 1 ms 364 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Incorrect 1 ms 364 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Incorrect 1 ms 364 KB Output isn't correct