Submission #963971

# Submission time Handle Problem Language Result Execution time Memory
963971 2024-04-16T06:08:58 Z Aiperiii Money (IZhO17_money) C++14
100 / 100
1136 ms 89480 KB
#include <bits/stdc++.h>
#define int long long
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
using namespace std;
signed main(){
    ios_base::sync_with_stdio();
    cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    vector <int> a(n+1);
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    vector <vector <int> > vec;
    vector <int> v;
    for(int i=1;i<=n;i++){
        if(a[i]>=a[i-1]){
            v.pb(a[i]);
        }
        else{
            vec.pb(v);
            v.clear();
            v.pb(a[i]);
        }
    }
    vec.pb(v);
    multiset <int> ms;
    for(auto x : vec[0])ms.insert(x);
    int ans=1;
    for(int i=1;i<vec.size();i++){
        int pos=0;
        while(pos<vec[i].size()){
            int x=vec[i][pos];
            auto it=ms.upper_bound(x);
            int up=*it;
            if(it==ms.end()){
                ans++;
                break;
            }
            else{
                auto it=upper_bound(all(vec[i]),up);
                ans++;
                pos=it-vec[i].begin();
            }
        }
        for(auto x : vec[i])ms.insert(x);
    }
    cout<<ans<<"\n";
}

/*
6
3 6 4 5 1 2
*/

Compilation message

money.cpp: In function 'int main()':
money.cpp:33:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |     for(int i=1;i<vec.size();i++){
      |                 ~^~~~~~~~~~~
money.cpp:35: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]
   35 |         while(pos<vec[i].size()){
      |               ~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 516 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 440 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 436 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 588 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 440 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 516 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 440 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 436 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 588 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 440 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 1 ms 436 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 0 ms 436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 516 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 440 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 436 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 588 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 440 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 1 ms 436 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 0 ms 436 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 360 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 1 ms 352 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 424 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 516 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 440 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 436 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 588 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 440 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 1 ms 436 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 0 ms 436 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 360 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 1 ms 352 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 424 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 229 ms 41036 KB Output is correct
40 Correct 440 ms 69096 KB Output is correct
41 Correct 162 ms 32760 KB Output is correct
42 Correct 176 ms 30540 KB Output is correct
43 Correct 117 ms 21712 KB Output is correct
44 Correct 596 ms 86720 KB Output is correct
45 Correct 557 ms 85948 KB Output is correct
46 Correct 604 ms 86808 KB Output is correct
47 Correct 403 ms 78808 KB Output is correct
48 Correct 481 ms 82076 KB Output is correct
49 Correct 800 ms 87364 KB Output is correct
50 Correct 740 ms 85872 KB Output is correct
51 Correct 780 ms 88176 KB Output is correct
52 Correct 734 ms 86088 KB Output is correct
53 Correct 704 ms 87012 KB Output is correct
54 Correct 735 ms 85824 KB Output is correct
55 Correct 1069 ms 89268 KB Output is correct
56 Correct 1012 ms 89304 KB Output is correct
57 Correct 1122 ms 89388 KB Output is correct
58 Correct 1062 ms 89372 KB Output is correct
59 Correct 1057 ms 89336 KB Output is correct
60 Correct 1063 ms 89456 KB Output is correct
61 Correct 1136 ms 89480 KB Output is correct
62 Correct 1085 ms 89464 KB Output is correct