답안 #890596

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
890596 2023-12-21T14:38:38 Z NoLove Rabbit Carrot (LMIO19_triusis) C++14
0 / 100
1 ms 2652 KB
/**
 *    author : Lăng Trọng Đạt
 *    created: 21-12-2023 
**/
#include <bits/stdc++.h>
using namespace std;
#ifndef LANG_DAT
#define db(...) ;
#endif // LANG_DAT
#define int int64_t
#define mp make_pair
#define f first
#define s second
#define pb push_back
#define all(v) (v).begin(), (v).end()
using pii = pair<int, int>;

const int MAXN = 2e5 + 5;
int g[MAXN], dp[MAXN];
int n, x;

int32_t main() {
    cin.tie(0)->sync_with_stdio(0);
    if (fopen("hi.inp", "r")) {
        freopen("hi.inp", "r", stdin);
//        freopen("hi.out", "w", stdout);
    } 

    cin >> n >> x;
    for (int i = 1; i <= n; i++) {
        cin >> g[i];
        g[i] -= i * x;
    }
    memset(dp, 0x3f3f, sizeof(dp));
    // if (g[1] > 0) {
    //     g[1] = 0;
    //     dp[1] = 1;
    // }
    // g[0] = -x;
    dp[0] = 0;
    dp[n] = n;
    for (int j = 1; j <= n; j++) {
        for (int i = 0; i < j; i++) {
            if (g[i] >= g[j]) {
                dp[j] = min(dp[j], dp[i] + (j - i - 1));
            }
        }
        db(dp[j])
    }
    cout << dp[n];
}

Compilation message

triusis.cpp: In function 'int32_t main()':
triusis.cpp:25:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |         freopen("hi.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Incorrect 1 ms 2652 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Incorrect 1 ms 2652 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Incorrect 1 ms 2652 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Incorrect 1 ms 2652 KB Output isn't correct
5 Halted 0 ms 0 KB -