Submission #671813

# Submission time Handle Problem Language Result Execution time Memory
671813 2022-12-14T03:20:10 Z ReLice Money (IZhO17_money) C++17
100 / 100
1002 ms 55236 KB
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
#define ld long double
#define int long long
#define pb push_back
#define sz size()
#define fr first
#define sc second
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
void start(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
const int N=1e6+5;
const int mod=1e9+7;
const int inf=1e7;
void solve(){
    ll n,i,mx=-1,l,r,k,ans=1,lst;
    cin>>n;
	vector <ll> v(n);
	multiset <ll> ms;
	for(i=0;i<n;i++) cin>>v[i];
	lst=v[0];
	ms.insert(v[0]);
	auto it=ms.end();
	for(i=1;i<n;i++){
        auto it1=ms.lower_bound(v[i]);
        auto it2=ms.upper_bound(v[i]);
        if(v[i]<lst || (it1!=it && it2!=it)){
            ans++;
            it=it2;
        }
        ms.insert(v[i]);
        lst=v[i];
	}
	cout<<ans<<endl;
}
signed main(){
    //fre("divide");
    start();
    ll t=1;
    //cin>>t;
    while(t--) solve();
}

Compilation message

money.cpp: In function 'void solve()':
money.cpp:22:12: warning: unused variable 'mx' [-Wunused-variable]
   22 |     ll n,i,mx=-1,l,r,k,ans=1,lst;
      |            ^~
money.cpp:22:18: warning: unused variable 'l' [-Wunused-variable]
   22 |     ll n,i,mx=-1,l,r,k,ans=1,lst;
      |                  ^
money.cpp:22:20: warning: unused variable 'r' [-Wunused-variable]
   22 |     ll n,i,mx=-1,l,r,k,ans=1,lst;
      |                    ^
money.cpp:22:22: warning: unused variable 'k' [-Wunused-variable]
   22 |     ll n,i,mx=-1,l,r,k,ans=1,lst;
      |                      ^
money.cpp: In function 'void fre(std::string)':
money.cpp:12:27: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 | void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                    ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
money.cpp:12:64: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 | void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                                                         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 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 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 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 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 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 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 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 0 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 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 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 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 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 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 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 0 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 0 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 1 ms 212 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 0 ms 212 KB Output is correct
36 Correct 0 ms 212 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 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 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 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 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 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 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 0 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 0 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 1 ms 212 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 0 ms 212 KB Output is correct
36 Correct 0 ms 212 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 194 ms 26612 KB Output is correct
40 Correct 383 ms 43492 KB Output is correct
41 Correct 148 ms 21552 KB Output is correct
42 Correct 167 ms 19044 KB Output is correct
43 Correct 106 ms 13516 KB Output is correct
44 Correct 490 ms 55152 KB Output is correct
45 Correct 465 ms 54984 KB Output is correct
46 Correct 485 ms 55196 KB Output is correct
47 Correct 334 ms 54996 KB Output is correct
48 Correct 379 ms 55072 KB Output is correct
49 Correct 678 ms 55056 KB Output is correct
50 Correct 617 ms 55008 KB Output is correct
51 Correct 683 ms 54988 KB Output is correct
52 Correct 631 ms 55144 KB Output is correct
53 Correct 667 ms 55152 KB Output is correct
54 Correct 635 ms 54988 KB Output is correct
55 Correct 932 ms 55128 KB Output is correct
56 Correct 963 ms 55092 KB Output is correct
57 Correct 944 ms 55236 KB Output is correct
58 Correct 955 ms 55120 KB Output is correct
59 Correct 940 ms 55116 KB Output is correct
60 Correct 951 ms 55068 KB Output is correct
61 Correct 1002 ms 55176 KB Output is correct
62 Correct 999 ms 55156 KB Output is correct