Submission #359057

# Submission time Handle Problem Language Result Execution time Memory
359057 2021-01-26T09:41:09 Z Ahmad_Hasan Money (IZhO17_money) C++17
45 / 100
1500 ms 55404 KB
#include <bits/stdc++.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);      cout.tie(0);
    int n;
    cin>>n;
    vector<int>v(n);

    for(int i=0;i<n;i++)
        cin>>v[i];
    int ans=0;
    set<int>ms;
    int f=0;
    int l=0;
    int vls[(int)1e6+5]={0};
    for(int i=0;i<n;i++){
        set<int>::iterator it1=ms.lower_bound(v[i]);
        set<int>::iterator it2=ms.upper_bound(v[i]);

        if((i+1<n)&&(v[i+1]<v[i]||(it2!=ms.end()&&*it2<v[i+1])||(it1!=ms.end()&&*it1>v[l]&&*it1<v[i+1]))){
            ans++;
            for(int j=l;j<=i;j++){
                if(!vls[v[j]])
                    ms.insert(v[j]);
                vls[v[j]]=1;
            }

            l=i+1;
        }

        if(i==n-1)
            ans++;
    }

    cout<<ans<<'\n';



    return 0;
}
/**
7
2 4 6 1 3 5 7
6
3 6 4 5 1 2
*/

Compilation message

money.cpp: In function 'int main()':
money.cpp:15:9: warning: unused variable 'f' [-Wunused-variable]
   15 |     int f=0;
      |         ^
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4204 KB Output is correct
2 Correct 3 ms 4204 KB Output is correct
3 Correct 2 ms 4204 KB Output is correct
4 Correct 2 ms 4204 KB Output is correct
5 Correct 3 ms 4204 KB Output is correct
6 Correct 2 ms 4204 KB Output is correct
7 Correct 2 ms 4204 KB Output is correct
8 Correct 2 ms 4204 KB Output is correct
9 Correct 2 ms 4204 KB Output is correct
10 Correct 3 ms 4204 KB Output is correct
11 Correct 3 ms 4204 KB Output is correct
12 Correct 3 ms 4204 KB Output is correct
13 Correct 3 ms 4204 KB Output is correct
14 Correct 3 ms 4204 KB Output is correct
15 Correct 2 ms 4204 KB Output is correct
16 Correct 3 ms 4204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4204 KB Output is correct
2 Correct 3 ms 4204 KB Output is correct
3 Correct 2 ms 4204 KB Output is correct
4 Correct 2 ms 4204 KB Output is correct
5 Correct 3 ms 4204 KB Output is correct
6 Correct 2 ms 4204 KB Output is correct
7 Correct 2 ms 4204 KB Output is correct
8 Correct 2 ms 4204 KB Output is correct
9 Correct 2 ms 4204 KB Output is correct
10 Correct 3 ms 4204 KB Output is correct
11 Correct 3 ms 4204 KB Output is correct
12 Correct 3 ms 4204 KB Output is correct
13 Correct 3 ms 4204 KB Output is correct
14 Correct 3 ms 4204 KB Output is correct
15 Correct 2 ms 4204 KB Output is correct
16 Correct 3 ms 4204 KB Output is correct
17 Correct 3 ms 4204 KB Output is correct
18 Correct 3 ms 4204 KB Output is correct
19 Correct 2 ms 4204 KB Output is correct
20 Correct 3 ms 4204 KB Output is correct
21 Correct 3 ms 4204 KB Output is correct
22 Correct 3 ms 4204 KB Output is correct
23 Correct 2 ms 4204 KB Output is correct
24 Correct 3 ms 4204 KB Output is correct
25 Correct 3 ms 4204 KB Output is correct
26 Correct 3 ms 4204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4204 KB Output is correct
2 Correct 3 ms 4204 KB Output is correct
3 Correct 2 ms 4204 KB Output is correct
4 Correct 2 ms 4204 KB Output is correct
5 Correct 3 ms 4204 KB Output is correct
6 Correct 2 ms 4204 KB Output is correct
7 Correct 2 ms 4204 KB Output is correct
8 Correct 2 ms 4204 KB Output is correct
9 Correct 2 ms 4204 KB Output is correct
10 Correct 3 ms 4204 KB Output is correct
11 Correct 3 ms 4204 KB Output is correct
12 Correct 3 ms 4204 KB Output is correct
13 Correct 3 ms 4204 KB Output is correct
14 Correct 3 ms 4204 KB Output is correct
15 Correct 2 ms 4204 KB Output is correct
16 Correct 3 ms 4204 KB Output is correct
17 Correct 3 ms 4204 KB Output is correct
18 Correct 3 ms 4204 KB Output is correct
19 Correct 2 ms 4204 KB Output is correct
20 Correct 3 ms 4204 KB Output is correct
21 Correct 3 ms 4204 KB Output is correct
22 Correct 3 ms 4204 KB Output is correct
23 Correct 2 ms 4204 KB Output is correct
24 Correct 3 ms 4204 KB Output is correct
25 Correct 3 ms 4204 KB Output is correct
26 Correct 3 ms 4204 KB Output is correct
27 Correct 2 ms 4204 KB Output is correct
28 Correct 3 ms 4332 KB Output is correct
29 Correct 4 ms 4204 KB Output is correct
30 Correct 3 ms 4204 KB Output is correct
31 Correct 3 ms 4204 KB Output is correct
32 Correct 3 ms 4204 KB Output is correct
33 Correct 3 ms 4204 KB Output is correct
34 Correct 3 ms 4204 KB Output is correct
35 Correct 2 ms 4204 KB Output is correct
36 Correct 3 ms 4204 KB Output is correct
37 Correct 3 ms 4204 KB Output is correct
38 Correct 3 ms 4204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4204 KB Output is correct
2 Correct 3 ms 4204 KB Output is correct
3 Correct 2 ms 4204 KB Output is correct
4 Correct 2 ms 4204 KB Output is correct
5 Correct 3 ms 4204 KB Output is correct
6 Correct 2 ms 4204 KB Output is correct
7 Correct 2 ms 4204 KB Output is correct
8 Correct 2 ms 4204 KB Output is correct
9 Correct 2 ms 4204 KB Output is correct
10 Correct 3 ms 4204 KB Output is correct
11 Correct 3 ms 4204 KB Output is correct
12 Correct 3 ms 4204 KB Output is correct
13 Correct 3 ms 4204 KB Output is correct
14 Correct 3 ms 4204 KB Output is correct
15 Correct 2 ms 4204 KB Output is correct
16 Correct 3 ms 4204 KB Output is correct
17 Correct 3 ms 4204 KB Output is correct
18 Correct 3 ms 4204 KB Output is correct
19 Correct 2 ms 4204 KB Output is correct
20 Correct 3 ms 4204 KB Output is correct
21 Correct 3 ms 4204 KB Output is correct
22 Correct 3 ms 4204 KB Output is correct
23 Correct 2 ms 4204 KB Output is correct
24 Correct 3 ms 4204 KB Output is correct
25 Correct 3 ms 4204 KB Output is correct
26 Correct 3 ms 4204 KB Output is correct
27 Correct 2 ms 4204 KB Output is correct
28 Correct 3 ms 4332 KB Output is correct
29 Correct 4 ms 4204 KB Output is correct
30 Correct 3 ms 4204 KB Output is correct
31 Correct 3 ms 4204 KB Output is correct
32 Correct 3 ms 4204 KB Output is correct
33 Correct 3 ms 4204 KB Output is correct
34 Correct 3 ms 4204 KB Output is correct
35 Correct 2 ms 4204 KB Output is correct
36 Correct 3 ms 4204 KB Output is correct
37 Correct 3 ms 4204 KB Output is correct
38 Correct 3 ms 4204 KB Output is correct
39 Correct 59 ms 6124 KB Output is correct
40 Correct 113 ms 7276 KB Output is correct
41 Correct 48 ms 5740 KB Output is correct
42 Correct 47 ms 5612 KB Output is correct
43 Correct 35 ms 5228 KB Output is correct
44 Correct 143 ms 8172 KB Output is correct
45 Correct 131 ms 8172 KB Output is correct
46 Correct 127 ms 8172 KB Output is correct
47 Correct 110 ms 8172 KB Output is correct
48 Correct 111 ms 8172 KB Output is correct
49 Correct 678 ms 26716 KB Output is correct
50 Correct 693 ms 26604 KB Output is correct
51 Correct 679 ms 26732 KB Output is correct
52 Correct 679 ms 26716 KB Output is correct
53 Correct 692 ms 26604 KB Output is correct
54 Correct 685 ms 26588 KB Output is correct
55 Correct 1489 ms 55404 KB Output is correct
56 Correct 1481 ms 55148 KB Output is correct
57 Execution timed out 1534 ms 55296 KB Time limit exceeded
58 Halted 0 ms 0 KB -