Submission #948010

# Submission time Handle Problem Language Result Execution time Memory
948010 2024-03-17T12:31:47 Z Pring Money (IZhO17_money) C++17
100 / 100
1158 ms 69968 KB
#include <bits/stdc++.h>
using namespace std;

#ifdef MIKU
string dbmc = "\033[1;38;2;57;197;187m", dbrs = "\033[0m";
#define debug(x...) cout << dbmc << "[" << #x << "]: ", dout(x)
void dout() { cout << dbrs << endl; }
template <typename T, typename ...U>
void dout(T t, U ...u) { cout << t << (sizeof...(u) ? ", " : ""); dout(u...); }
#else
#define debug(...) 39
#endif

#define int long long
#define fs first
#define sc second
#define mp make_pair
#define FOR(i, j, k) for (int i = j, Z = k; i < Z; i++)
typedef pair<int, int> pii;

const int MXN = 1000005;
int n;
vector<int> v;
int a[MXN];
multiset<int> MS;

int f(int sr) {
    auto it = MS.find(a[sr]);
    FOR(i, sr + 1, n) {
        it = MS.erase(it);
        if (it == MS.begin()) return i;
        it = prev(it);
        if (*it != a[i]) return i;
    }
    return n;
}

void miku() {
    cin >> n;
    v.resize(n);
    for (auto &i : v) cin >> i;
    n = 0;
    for (int i = 0, j = 0; i < v.size(); i = j) {
        while (j < v.size() && v[i] == v[j]) j++;
        a[n] = v[i];
        n++;
    }
    FOR(i, 0, n) MS.insert(a[i]);
    reverse(a, a + n);
    int ans = 0, now = 0;
    while (now < n) {
        now = f(now);
        ans++;
    }
    cout << ans << '\n';
}

int32_t main() {
    cin.tie(0) -> sync_with_stdio(false);
    cin.exceptions(cin.failbit);
    miku();
    return 0;
}

Compilation message

money.cpp: In function 'void miku()':
money.cpp:43:30: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |     for (int i = 0, j = 0; i < v.size(); i = j) {
      |                            ~~^~~~~~~~~~
money.cpp:44:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |         while (j < v.size() && v[i] == v[j]) j++;
      |                ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 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 0 ms 348 KB Output is correct
5 Correct 0 ms 348 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 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 600 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 0 ms 348 KB Output is correct
5 Correct 0 ms 348 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 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 600 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 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 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 0 ms 348 KB Output is correct
5 Correct 0 ms 348 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 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 600 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 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 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 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 348 KB Output is correct
33 Correct 1 ms 600 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 1 ms 600 KB Output is correct
36 Correct 0 ms 468 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 1 ms 548 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 0 ms 348 KB Output is correct
5 Correct 0 ms 348 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 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 600 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 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 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 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 348 KB Output is correct
33 Correct 1 ms 600 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 1 ms 600 KB Output is correct
36 Correct 0 ms 468 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 1 ms 548 KB Output is correct
39 Correct 129 ms 29608 KB Output is correct
40 Correct 278 ms 51888 KB Output is correct
41 Correct 91 ms 23892 KB Output is correct
42 Correct 118 ms 24724 KB Output is correct
43 Correct 86 ms 17112 KB Output is correct
44 Correct 315 ms 62724 KB Output is correct
45 Correct 287 ms 60500 KB Output is correct
46 Correct 367 ms 62940 KB Output is correct
47 Correct 214 ms 42780 KB Output is correct
48 Correct 243 ms 52668 KB Output is correct
49 Correct 569 ms 64340 KB Output is correct
50 Correct 567 ms 60576 KB Output is correct
51 Correct 607 ms 65924 KB Output is correct
52 Correct 563 ms 60552 KB Output is correct
53 Correct 590 ms 62944 KB Output is correct
54 Correct 566 ms 60760 KB Output is correct
55 Correct 1097 ms 69792 KB Output is correct
56 Correct 1052 ms 69796 KB Output is correct
57 Correct 1099 ms 69632 KB Output is correct
58 Correct 1004 ms 69716 KB Output is correct
59 Correct 1158 ms 69968 KB Output is correct
60 Correct 1082 ms 69812 KB Output is correct
61 Correct 1020 ms 69588 KB Output is correct
62 Correct 1077 ms 69748 KB Output is correct