답안 #855180

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
855180 2023-09-30T13:12:30 Z ooscode Stove (JOI18_stove) C++17
50 / 100
1000 ms 262148 KB
// IN THE NAME OF ALLAH
// YA IMAM REZA

#include<bits/stdc++.h>
 
using namespace std;
 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define wall cerr << "------------------------------------" << endl
#define pb push_back
#define pob pop_back
#define F first
#define S second
#define all(x) x.begin() , x.end()
#define int ll
#define kids int tm = (tl + tr)>>1; int cl = v<<1; int cr = v<<1|1
#define test int n;cin >> n;while(n--)
#define file freopen("input.txt" , "r" , stdin); freopen("output.txt" , "w" , stdout)
#define debug while(1) cout << "TEST\n"

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
#pragma GCC optimize("Ofast")
 
typedef long long ll;
typedef pair<int , int> pii;
typedef pair<ll , ll> pll;
typedef pair<pii,int> piii;
typedef pair<pll , ll> plll;
 
const int N = 5e3+10;
const int K = 400+10;
const ll mod = 1e9+7;
const ll INF = 1e9+10;
const int P = 31;
const int lg = 25;

const int delta = 30103; 

int dp[N][N];
int t[N];
int n , k;
void solve() {
    for(int i = 0 ; i < N ; i++)
        for(int j = 0 ; j < N ; j++)
            dp[i][j] = INF;
    dp[1][1] = 1;

    cin >> n >> k;
    for(int i = 1 ; i <= n ; i++)
        cin >> t[i];
    for(int i = 2 ; i <= n ; i++) {
        // wall;
        dp[i][1] = dp[i-1][1] + t[i] - t[i-1];
        // cout << i << " " << 1 << " " << dp[i][1] << "\n";
        for(int j = 2 ; j <= min(i , k) ; j++) {
            dp[i][j] = min(dp[i-1][j-1] + 1 , dp[i-1][j] + (t[i] - t[i-1]));
            // cout << i << " " << j << " " << dp[i][j] << " deb\n";
        }
    }

    cout << dp[n][k] << "\n";
}

signed main()
{   
    fast;
    solve();
} 
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 196716 KB Output is correct
2 Correct 23 ms 196692 KB Output is correct
3 Correct 28 ms 196952 KB Output is correct
4 Correct 23 ms 196848 KB Output is correct
5 Correct 24 ms 196764 KB Output is correct
6 Correct 22 ms 196700 KB Output is correct
7 Correct 23 ms 196688 KB Output is correct
8 Correct 22 ms 196688 KB Output is correct
9 Correct 23 ms 196700 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 196716 KB Output is correct
2 Correct 23 ms 196692 KB Output is correct
3 Correct 28 ms 196952 KB Output is correct
4 Correct 23 ms 196848 KB Output is correct
5 Correct 24 ms 196764 KB Output is correct
6 Correct 22 ms 196700 KB Output is correct
7 Correct 23 ms 196688 KB Output is correct
8 Correct 22 ms 196688 KB Output is correct
9 Correct 23 ms 196700 KB Output is correct
10 Correct 23 ms 196944 KB Output is correct
11 Correct 23 ms 196860 KB Output is correct
12 Correct 27 ms 196988 KB Output is correct
13 Correct 28 ms 196952 KB Output is correct
14 Correct 27 ms 196952 KB Output is correct
15 Correct 29 ms 196932 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 196716 KB Output is correct
2 Correct 23 ms 196692 KB Output is correct
3 Correct 28 ms 196952 KB Output is correct
4 Correct 23 ms 196848 KB Output is correct
5 Correct 24 ms 196764 KB Output is correct
6 Correct 22 ms 196700 KB Output is correct
7 Correct 23 ms 196688 KB Output is correct
8 Correct 22 ms 196688 KB Output is correct
9 Correct 23 ms 196700 KB Output is correct
10 Correct 23 ms 196944 KB Output is correct
11 Correct 23 ms 196860 KB Output is correct
12 Correct 27 ms 196988 KB Output is correct
13 Correct 28 ms 196952 KB Output is correct
14 Correct 27 ms 196952 KB Output is correct
15 Correct 29 ms 196932 KB Output is correct
16 Execution timed out 2276 ms 262148 KB Time limit exceeded
17 Halted 0 ms 0 KB -