Submission #575421

# Submission time Handle Problem Language Result Execution time Memory
575421 2022-06-10T11:31:12 Z Trent Rabbit Carrot (LMIO19_triusis) C++14
63 / 100
1000 ms 39148 KB
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"

using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define open(g) string _name_ = g; freopen((_name_ + ".in").c_str(), "r", stdin); freopen((_name_ + ".out").c_str(), "w", stdout)
#define printArr(a, len) for(int asdf = 0; asdf < (len); ++asdf) cout << (a)[asdf] << ' '; cout << '\n';
#define boost() cin.sync_with_stdio(0); cin.tie(0)
#define forR(i, x) for(int i = 0; i < x; ++i)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define all(i) i.begin(), i.end()
#define pii pair<int, int>
#define vi vector<int>
#define si set<int>
#define usi unordered_set<int>
#define mii map<int, int>
#define umii unordered_map<int, int>
template <class K, class V> using ht = gp_hash_table<K, V, hash<K>, equal_to<K>, direct_mask_range_hashing<>,
linear_probe_fn<>, hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<>, true>>;

const ll MIN = 1e9 + 10, MAX=3e9 + 10, MN = 2e5 + 10;
gp_hash_table<ll, ll> bit;
ll& get(ll i){
    if(bit.find(i) == bit.end()) return bit[i] = MAX;
    return bit[i];
}
void upd(ll i, ll diff){
    i = MIN - i;
    assert(0 < i && i < MAX);
    for(; i < MAX; i += i&-i) get(i) = min(get(i), diff);
}
ll qu(ll i){
    i = MIN - i;
    assert(0 < i && i < MAX);
    ll ma = MAX;
    for(; i > 0; i -= i&-i) ma = min(ma, get(i));
    return ma;
}

ll dp[MN];

signed main() {
    int n, m;
    cin >> n >> m;
    upd(0, 0);

    REP(i, 1, n + 1){
        int a;
        cin >> a;
        dp[i] = qu(a - i * m) + i - 1;
        upd(a - i * m, dp[i] - i);
    }
    ll mi = n;
    REP(i, 1, n + 1) {
        mi = min(mi, dp[i] + n - i);
    }
    cout << mi << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 304 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 304 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 312 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 6 ms 660 KB Output is correct
21 Correct 8 ms 1588 KB Output is correct
22 Correct 8 ms 724 KB Output is correct
23 Correct 53 ms 5072 KB Output is correct
24 Correct 64 ms 5084 KB Output is correct
25 Correct 10 ms 2764 KB Output is correct
26 Correct 23 ms 5076 KB Output is correct
27 Correct 11 ms 348 KB Output is correct
28 Correct 11 ms 344 KB Output is correct
29 Correct 8 ms 1616 KB Output is correct
30 Correct 10 ms 2764 KB Output is correct
31 Correct 8 ms 704 KB Output is correct
32 Correct 39 ms 5056 KB Output is correct
33 Correct 42 ms 5056 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 6 ms 660 KB Output is correct
5 Correct 8 ms 1588 KB Output is correct
6 Correct 8 ms 724 KB Output is correct
7 Correct 53 ms 5072 KB Output is correct
8 Correct 64 ms 5084 KB Output is correct
9 Correct 10 ms 2764 KB Output is correct
10 Correct 23 ms 5076 KB Output is correct
11 Correct 11 ms 348 KB Output is correct
12 Correct 11 ms 344 KB Output is correct
13 Correct 8 ms 1616 KB Output is correct
14 Correct 10 ms 2764 KB Output is correct
15 Correct 8 ms 704 KB Output is correct
16 Correct 39 ms 5056 KB Output is correct
17 Correct 42 ms 5056 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 308 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 0 ms 304 KB Output is correct
32 Correct 0 ms 212 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 537 ms 9728 KB Output is correct
35 Correct 520 ms 9656 KB Output is correct
36 Correct 552 ms 9696 KB Output is correct
37 Correct 21 ms 5064 KB Output is correct
38 Correct 12 ms 320 KB Output is correct
39 Correct 13 ms 340 KB Output is correct
40 Correct 7 ms 724 KB Output is correct
41 Correct 14 ms 356 KB Output is correct
42 Correct 72 ms 5244 KB Output is correct
43 Correct 74 ms 5092 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 537 ms 9728 KB Output is correct
2 Correct 520 ms 9656 KB Output is correct
3 Correct 552 ms 9696 KB Output is correct
4 Correct 21 ms 5064 KB Output is correct
5 Correct 12 ms 320 KB Output is correct
6 Correct 13 ms 340 KB Output is correct
7 Correct 7 ms 724 KB Output is correct
8 Correct 14 ms 356 KB Output is correct
9 Correct 72 ms 5244 KB Output is correct
10 Correct 74 ms 5092 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 312 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 6 ms 660 KB Output is correct
15 Correct 8 ms 1588 KB Output is correct
16 Correct 8 ms 724 KB Output is correct
17 Correct 53 ms 5072 KB Output is correct
18 Correct 64 ms 5084 KB Output is correct
19 Correct 10 ms 2764 KB Output is correct
20 Correct 23 ms 5076 KB Output is correct
21 Correct 11 ms 348 KB Output is correct
22 Correct 11 ms 344 KB Output is correct
23 Correct 8 ms 1616 KB Output is correct
24 Correct 10 ms 2764 KB Output is correct
25 Correct 8 ms 704 KB Output is correct
26 Correct 39 ms 5056 KB Output is correct
27 Correct 42 ms 5056 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 308 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 0 ms 212 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 0 ms 304 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 0 ms 212 KB Output is correct
44 Correct 245 ms 39148 KB Output is correct
45 Execution timed out 1082 ms 19324 KB Time limit exceeded
46 Halted 0 ms 0 KB -