답안 #959464

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
959464 2024-04-08T09:00:05 Z steveonalex Rabbit Carrot (LMIO19_triusis) C++17
63 / 100
1000 ms 2392 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define MASK(i) (1LL << (i))
#define GETBIT(mask, i) (((mask) >> (i)) & 1)
#define ALL(v) (v).begin(), (v).end()

ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}

ll LASTBIT(ll mask){return (mask) & (-mask);}
int pop_cnt(ll mask){return __builtin_popcountll(mask);}
int ctz(ll mask){return __builtin_ctzll(mask);}
int logOf(ll mask){return 63 - __builtin_clzll(mask);}

mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
// mt19937_64 rng(69);
ll rngesus(ll l, ll r){return l + (ull) rng() % (r - l + 1);}

template <class T1, class T2>
    bool maximize(T1 &a, T2 b){
        if (a < b) {a = b; return true;}
        return false;
    }

template <class T1, class T2>
    bool minimize(T1 &a, T2 b){
        if (a > b) {a = b; return true;}
        return false;
    }

template <class T>
    void printArr(T& container, string separator = " ", string finish = "\n", ostream &out = cout){
        for(auto item: container) out << item << separator;
        out << finish;
    }

template <class T>
    void remove_dup(vector<T> &a){
        sort(ALL(a));
        a.resize(unique(ALL(a)) - a.begin());
    }

const int N = 2e5 + 69;
const int INF = 1e9 + 69;
int dp[N];

int main(void){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int n, d; cin >> n >> d;
    vector<int> a(n+2);
    for(int i= 1; i<=n; ++i) cin >> a[i];

    for(int i= 1; i<=n+1; ++i) dp[i] = INF;
    for(int i= 1; i<=n; ++i){
        if (a[i] - a[i-1] <= d) minimize(dp[i], dp[i-1]);
        for(int j = 1; j<=i; ++j){
            int l = j, r = i;
            int chode = a[l - 1];
            int sigma = chode + 1LL * (r - l + 1) * d;
            if (a[r+1] - sigma <= d)
                minimize(dp[r+1], dp[l-1] + (r - l + 1));
        }  
    }

    int ans = min(dp[n], dp[n+1]);
    cout << ans << "\n";

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 600 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 468 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 600 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 468 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 9 ms 464 KB Output is correct
21 Correct 12 ms 348 KB Output is correct
22 Correct 42 ms 508 KB Output is correct
23 Correct 12 ms 600 KB Output is correct
24 Correct 12 ms 600 KB Output is correct
25 Correct 19 ms 348 KB Output is correct
26 Correct 15 ms 348 KB Output is correct
27 Correct 32 ms 344 KB Output is correct
28 Correct 17 ms 348 KB Output is correct
29 Correct 12 ms 348 KB Output is correct
30 Correct 19 ms 528 KB Output is correct
31 Correct 16 ms 528 KB Output is correct
32 Correct 16 ms 352 KB Output is correct
33 Correct 21 ms 352 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 9 ms 464 KB Output is correct
5 Correct 12 ms 348 KB Output is correct
6 Correct 42 ms 508 KB Output is correct
7 Correct 12 ms 600 KB Output is correct
8 Correct 12 ms 600 KB Output is correct
9 Correct 19 ms 348 KB Output is correct
10 Correct 15 ms 348 KB Output is correct
11 Correct 32 ms 344 KB Output is correct
12 Correct 17 ms 348 KB Output is correct
13 Correct 12 ms 348 KB Output is correct
14 Correct 19 ms 528 KB Output is correct
15 Correct 16 ms 528 KB Output is correct
16 Correct 16 ms 352 KB Output is correct
17 Correct 21 ms 352 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 1 ms 600 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 344 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 468 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 38 ms 348 KB Output is correct
35 Correct 38 ms 344 KB Output is correct
36 Correct 38 ms 348 KB Output is correct
37 Correct 17 ms 348 KB Output is correct
38 Correct 33 ms 532 KB Output is correct
39 Correct 17 ms 344 KB Output is correct
40 Correct 13 ms 348 KB Output is correct
41 Correct 12 ms 348 KB Output is correct
42 Correct 21 ms 348 KB Output is correct
43 Correct 15 ms 536 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 348 KB Output is correct
2 Correct 38 ms 344 KB Output is correct
3 Correct 38 ms 348 KB Output is correct
4 Correct 17 ms 348 KB Output is correct
5 Correct 33 ms 532 KB Output is correct
6 Correct 17 ms 344 KB Output is correct
7 Correct 13 ms 348 KB Output is correct
8 Correct 12 ms 348 KB Output is correct
9 Correct 21 ms 348 KB Output is correct
10 Correct 15 ms 536 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 9 ms 464 KB Output is correct
15 Correct 12 ms 348 KB Output is correct
16 Correct 42 ms 508 KB Output is correct
17 Correct 12 ms 600 KB Output is correct
18 Correct 12 ms 600 KB Output is correct
19 Correct 19 ms 348 KB Output is correct
20 Correct 15 ms 348 KB Output is correct
21 Correct 32 ms 344 KB Output is correct
22 Correct 17 ms 348 KB Output is correct
23 Correct 12 ms 348 KB Output is correct
24 Correct 19 ms 528 KB Output is correct
25 Correct 16 ms 528 KB Output is correct
26 Correct 16 ms 352 KB Output is correct
27 Correct 21 ms 352 KB Output is correct
28 Correct 0 ms 344 KB Output is correct
29 Correct 1 ms 600 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 344 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 468 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 1 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 1 ms 348 KB Output is correct
42 Correct 1 ms 348 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Execution timed out 1006 ms 2392 KB Time limit exceeded
45 Halted 0 ms 0 KB -