답안 #686625

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
686625 2023-01-25T15:09:50 Z toma_ariciu Money (IZhO17_money) C++17
100 / 100
1188 ms 58080 KB
/// banii banii banii
/// 2 locuri in masina ca milionarii
#include <iostream>
#include <set>

using namespace std;

const int maxN = 1000005;
int n, v[maxN], ans = 1;
set <int> values;

int solve(int poz)
{
    auto it = values.upper_bound(v[poz]);
    int aux, maxval;
    if(it == values.end())
        maxval = maxN;
    else
        maxval = (*it);
    bool ok = 1;
    for(aux = poz + 1; aux <= n; aux++)
        if(v[aux] < v[aux - 1] || v[aux] > maxval)
            {ok = 0; break;}
    for(int i = poz; i < aux; i++)
        values.insert(v[i]);
    return aux + ok;
}

int main()
{
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> v[i];
    int poz = n + 1;
    for(int i = 2; i <= n && (poz == n + 1); i++)
        if(v[i] < v[i - 1])
            poz = i;
    for(int i = 1; i < poz; i++)
        values.insert(v[i]);
    while(poz <= n)
    {
        poz = solve(poz);
        ans++;
    }
    cout << ans;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 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 0 ms 212 KB Output is correct
8 Correct 0 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 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 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 0 ms 212 KB Output is correct
8 Correct 0 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 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 312 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 304 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 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 0 ms 212 KB Output is correct
8 Correct 0 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 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 312 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 304 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 312 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 308 KB Output is correct
33 Correct 1 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
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 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 0 ms 212 KB Output is correct
8 Correct 0 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 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 312 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 304 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 312 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 308 KB Output is correct
33 Correct 1 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 145 ms 5420 KB Output is correct
40 Correct 247 ms 8692 KB Output is correct
41 Correct 119 ms 4376 KB Output is correct
42 Correct 107 ms 3892 KB Output is correct
43 Correct 78 ms 2904 KB Output is correct
44 Correct 320 ms 10868 KB Output is correct
45 Correct 328 ms 10908 KB Output is correct
46 Correct 313 ms 10956 KB Output is correct
47 Correct 300 ms 10992 KB Output is correct
48 Correct 309 ms 11024 KB Output is correct
49 Correct 604 ms 29364 KB Output is correct
50 Correct 590 ms 29416 KB Output is correct
51 Correct 572 ms 29404 KB Output is correct
52 Correct 584 ms 29356 KB Output is correct
53 Correct 614 ms 29388 KB Output is correct
54 Correct 570 ms 29188 KB Output is correct
55 Correct 1089 ms 58004 KB Output is correct
56 Correct 1188 ms 57940 KB Output is correct
57 Correct 1130 ms 57884 KB Output is correct
58 Correct 1128 ms 57892 KB Output is correct
59 Correct 1089 ms 57892 KB Output is correct
60 Correct 1103 ms 58080 KB Output is correct
61 Correct 1118 ms 57816 KB Output is correct
62 Correct 1117 ms 57948 KB Output is correct