답안 #86783

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
86783 2018-11-27T12:35:13 Z inom Money (IZhO17_money) C++14
100 / 100
1473 ms 166560 KB
#include<bits/stdc++.h>

#define fi first
#define se second
#define sc scanf
#define pr printf
#define pb push_back
#define int long long
#define sz(c) (int)(c).size()
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define in freopen("parking.in", "r", stdin);
#define out freopen("parking.out", "w", stdout);

using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("fast-math")
#pragma warning(disable : 4996)

const int N = 1000100;
const int INF = 1e15;

int TN = 1;

int n;
int ans;
int a[N];
multiset<int> st;

void solve() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    for (int i = 1; i <= n; i++) {   
        int cur;
        if (st.upper_bound(a[i]) == st.end()) {
            st.insert(INF); cur = INF; st.insert(a[i]);
        }
        else {
            cur = *st.upper_bound(a[i]); st.insert(a[i]);
        }
        int j = i;
        while (j + 1 <= n && a[j] <= a[j + 1] && a[j + 1] <= cur) {
            j++; st.insert(a[j]);
        }
        ans++; i = j;
    }
    cout << ans << "\n";
    return;
}

signed main() {
    ios_base::sync_with_stdio(0);
    // in; out; // cin >> TN;
    while (TN--) solve();
    return 0;
 }

Compilation message

money.cpp:22:0: warning: ignoring #pragma warning  [-Wunknown-pragmas]
 #pragma warning(disable : 4996)
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 440 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 3 ms 504 KB Output is correct
6 Correct 2 ms 680 KB Output is correct
7 Correct 2 ms 680 KB Output is correct
8 Correct 2 ms 680 KB Output is correct
9 Correct 2 ms 680 KB Output is correct
10 Correct 2 ms 680 KB Output is correct
11 Correct 2 ms 680 KB Output is correct
12 Correct 2 ms 680 KB Output is correct
13 Correct 2 ms 680 KB Output is correct
14 Correct 2 ms 680 KB Output is correct
15 Correct 2 ms 680 KB Output is correct
16 Correct 2 ms 712 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 440 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 3 ms 504 KB Output is correct
6 Correct 2 ms 680 KB Output is correct
7 Correct 2 ms 680 KB Output is correct
8 Correct 2 ms 680 KB Output is correct
9 Correct 2 ms 680 KB Output is correct
10 Correct 2 ms 680 KB Output is correct
11 Correct 2 ms 680 KB Output is correct
12 Correct 2 ms 680 KB Output is correct
13 Correct 2 ms 680 KB Output is correct
14 Correct 2 ms 680 KB Output is correct
15 Correct 2 ms 680 KB Output is correct
16 Correct 2 ms 712 KB Output is correct
17 Correct 2 ms 712 KB Output is correct
18 Correct 2 ms 712 KB Output is correct
19 Correct 2 ms 712 KB Output is correct
20 Correct 2 ms 712 KB Output is correct
21 Correct 2 ms 712 KB Output is correct
22 Correct 2 ms 712 KB Output is correct
23 Correct 2 ms 712 KB Output is correct
24 Correct 2 ms 712 KB Output is correct
25 Correct 2 ms 712 KB Output is correct
26 Correct 2 ms 712 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 440 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 3 ms 504 KB Output is correct
6 Correct 2 ms 680 KB Output is correct
7 Correct 2 ms 680 KB Output is correct
8 Correct 2 ms 680 KB Output is correct
9 Correct 2 ms 680 KB Output is correct
10 Correct 2 ms 680 KB Output is correct
11 Correct 2 ms 680 KB Output is correct
12 Correct 2 ms 680 KB Output is correct
13 Correct 2 ms 680 KB Output is correct
14 Correct 2 ms 680 KB Output is correct
15 Correct 2 ms 680 KB Output is correct
16 Correct 2 ms 712 KB Output is correct
17 Correct 2 ms 712 KB Output is correct
18 Correct 2 ms 712 KB Output is correct
19 Correct 2 ms 712 KB Output is correct
20 Correct 2 ms 712 KB Output is correct
21 Correct 2 ms 712 KB Output is correct
22 Correct 2 ms 712 KB Output is correct
23 Correct 2 ms 712 KB Output is correct
24 Correct 2 ms 712 KB Output is correct
25 Correct 2 ms 712 KB Output is correct
26 Correct 2 ms 712 KB Output is correct
27 Correct 2 ms 712 KB Output is correct
28 Correct 2 ms 712 KB Output is correct
29 Correct 2 ms 712 KB Output is correct
30 Correct 2 ms 712 KB Output is correct
31 Correct 2 ms 712 KB Output is correct
32 Correct 2 ms 712 KB Output is correct
33 Correct 2 ms 712 KB Output is correct
34 Correct 2 ms 796 KB Output is correct
35 Correct 2 ms 796 KB Output is correct
36 Correct 2 ms 796 KB Output is correct
37 Correct 2 ms 796 KB Output is correct
38 Correct 2 ms 796 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 440 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 3 ms 504 KB Output is correct
6 Correct 2 ms 680 KB Output is correct
7 Correct 2 ms 680 KB Output is correct
8 Correct 2 ms 680 KB Output is correct
9 Correct 2 ms 680 KB Output is correct
10 Correct 2 ms 680 KB Output is correct
11 Correct 2 ms 680 KB Output is correct
12 Correct 2 ms 680 KB Output is correct
13 Correct 2 ms 680 KB Output is correct
14 Correct 2 ms 680 KB Output is correct
15 Correct 2 ms 680 KB Output is correct
16 Correct 2 ms 712 KB Output is correct
17 Correct 2 ms 712 KB Output is correct
18 Correct 2 ms 712 KB Output is correct
19 Correct 2 ms 712 KB Output is correct
20 Correct 2 ms 712 KB Output is correct
21 Correct 2 ms 712 KB Output is correct
22 Correct 2 ms 712 KB Output is correct
23 Correct 2 ms 712 KB Output is correct
24 Correct 2 ms 712 KB Output is correct
25 Correct 2 ms 712 KB Output is correct
26 Correct 2 ms 712 KB Output is correct
27 Correct 2 ms 712 KB Output is correct
28 Correct 2 ms 712 KB Output is correct
29 Correct 2 ms 712 KB Output is correct
30 Correct 2 ms 712 KB Output is correct
31 Correct 2 ms 712 KB Output is correct
32 Correct 2 ms 712 KB Output is correct
33 Correct 2 ms 712 KB Output is correct
34 Correct 2 ms 796 KB Output is correct
35 Correct 2 ms 796 KB Output is correct
36 Correct 2 ms 796 KB Output is correct
37 Correct 2 ms 796 KB Output is correct
38 Correct 2 ms 796 KB Output is correct
39 Correct 241 ms 30332 KB Output is correct
40 Correct 501 ms 52504 KB Output is correct
41 Correct 222 ms 52504 KB Output is correct
42 Correct 204 ms 52504 KB Output is correct
43 Correct 134 ms 52504 KB Output is correct
44 Correct 614 ms 77372 KB Output is correct
45 Correct 536 ms 83984 KB Output is correct
46 Correct 605 ms 86020 KB Output is correct
47 Correct 434 ms 86432 KB Output is correct
48 Correct 433 ms 93168 KB Output is correct
49 Correct 1070 ms 100040 KB Output is correct
50 Correct 999 ms 106588 KB Output is correct
51 Correct 1050 ms 113428 KB Output is correct
52 Correct 947 ms 120268 KB Output is correct
53 Correct 1098 ms 126888 KB Output is correct
54 Correct 932 ms 133524 KB Output is correct
55 Correct 1452 ms 140440 KB Output is correct
56 Correct 1471 ms 146928 KB Output is correct
57 Correct 1473 ms 153760 KB Output is correct
58 Correct 1431 ms 160512 KB Output is correct
59 Correct 1372 ms 166416 KB Output is correct
60 Correct 1345 ms 166432 KB Output is correct
61 Correct 1383 ms 166432 KB Output is correct
62 Correct 1471 ms 166560 KB Output is correct