Submission #910588

# Submission time Handle Problem Language Result Execution time Memory
910588 2024-01-18T06:05:54 Z vjudge1 Money (IZhO17_money) C++17
45 / 100
1500 ms 81700 KB
/*#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt")*/
#include <bits/stdc++.h>
#include <iomanip>
#define ll long long
#define int long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define str string
#define pii pair<int,int>
#define sz(x) x.size()
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define mii map<int,int>
#define mll map<ll,ll>
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define yess cout<<"Yes\n";
#define noo cout<<"No\n";
using namespace std;

int t[4000001],sum=0;

void get(int v,int tl,int tr,int l,int r){
    if(tl>=l && tr<=r){
        sum+=t[v];
        return;
    }
    if(tl>r || tr<l){
        return;
    }
    int tm=(tl+tr)>>1;
    get(v+v,tl,tm,l,r);
    get(v+v+1,tm+1,tr,l,r);
}

void upd(int v,int tl,int tr,int l,int r){
    if(l<=tl && tr<=r){
        t[v]=1;
        return;
    }
    if(tl>r || tr<l){
        return;
    }
    int tm=(tl+tr)>>1;
    upd(v+v,tl,tm,l,r);
    upd(v+v+1,tm+1,tr,l,r);
    t[v]=t[v+v]+t[v+v+1];
}

void solve(){
    int n;
    cin>>n;
    int a[n+3];
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    int ans=0;
    a[0]=-1;
    map<int ,int>pp;
    for(int i=1;i<=n;i++){
        int o=i;
        for(int j=i+1;j<=n;j++){
            if(a[j]<a[j-1]){
                break;
            }
            sum=0;
            get(1,1,1000000,a[i],a[j]);
            //cout<<sum<<" "<<pp[a[i]]<<" "<<pp[a[j]]<<"\n";
            if(sum-pp[a[i]]-pp[a[j]]>0){
                o=j-1;
                break;
            }
            else{
                o=j;
            }
        }
        for(int j=i;j<=o;j++){
            upd(1,1,1000000,a[j],a[j]);
            pp[a[j]]=1;
        }
        ans++;
        i=o;
    }
    cout<<ans;
}
signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	//srand( time(0));
	//rand()
	//freopen("sum.in", "r", stdin);
	//freopen("sum.out", "w", stdout);
    int tests=1;
    //cin>>tests;
    for(int i=1;i<=tests;i++){
		//cout<<"TEST CASE : "<<i<<"\n";
		solve();
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 4700 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 4700 KB Output is correct
10 Correct 2 ms 12636 KB Output is correct
11 Correct 2 ms 6488 KB Output is correct
12 Correct 2 ms 12632 KB Output is correct
13 Correct 1 ms 6492 KB Output is correct
14 Correct 2 ms 8540 KB Output is correct
15 Correct 2 ms 10588 KB Output is correct
16 Correct 2 ms 10596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 4700 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 4700 KB Output is correct
10 Correct 2 ms 12636 KB Output is correct
11 Correct 2 ms 6488 KB Output is correct
12 Correct 2 ms 12632 KB Output is correct
13 Correct 1 ms 6492 KB Output is correct
14 Correct 2 ms 8540 KB Output is correct
15 Correct 2 ms 10588 KB Output is correct
16 Correct 2 ms 10596 KB Output is correct
17 Correct 1 ms 4952 KB Output is correct
18 Correct 1 ms 4700 KB Output is correct
19 Correct 1 ms 4700 KB Output is correct
20 Correct 2 ms 8540 KB Output is correct
21 Correct 2 ms 6748 KB Output is correct
22 Correct 1 ms 4444 KB Output is correct
23 Correct 2 ms 8540 KB Output is correct
24 Correct 2 ms 10588 KB Output is correct
25 Correct 2 ms 9052 KB Output is correct
26 Correct 2 ms 8796 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 4700 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 4700 KB Output is correct
10 Correct 2 ms 12636 KB Output is correct
11 Correct 2 ms 6488 KB Output is correct
12 Correct 2 ms 12632 KB Output is correct
13 Correct 1 ms 6492 KB Output is correct
14 Correct 2 ms 8540 KB Output is correct
15 Correct 2 ms 10588 KB Output is correct
16 Correct 2 ms 10596 KB Output is correct
17 Correct 1 ms 4952 KB Output is correct
18 Correct 1 ms 4700 KB Output is correct
19 Correct 1 ms 4700 KB Output is correct
20 Correct 2 ms 8540 KB Output is correct
21 Correct 2 ms 6748 KB Output is correct
22 Correct 1 ms 4444 KB Output is correct
23 Correct 2 ms 8540 KB Output is correct
24 Correct 2 ms 10588 KB Output is correct
25 Correct 2 ms 9052 KB Output is correct
26 Correct 2 ms 8796 KB Output is correct
27 Correct 1 ms 6500 KB Output is correct
28 Correct 1 ms 6540 KB Output is correct
29 Correct 1 ms 6492 KB Output is correct
30 Correct 1 ms 2404 KB Output is correct
31 Correct 2 ms 6492 KB Output is correct
32 Correct 2 ms 8784 KB Output is correct
33 Correct 2 ms 4696 KB Output is correct
34 Correct 2 ms 4696 KB Output is correct
35 Correct 1 ms 468 KB Output is correct
36 Correct 1 ms 4700 KB Output is correct
37 Correct 3 ms 12376 KB Output is correct
38 Correct 3 ms 14940 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 4700 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 4700 KB Output is correct
10 Correct 2 ms 12636 KB Output is correct
11 Correct 2 ms 6488 KB Output is correct
12 Correct 2 ms 12632 KB Output is correct
13 Correct 1 ms 6492 KB Output is correct
14 Correct 2 ms 8540 KB Output is correct
15 Correct 2 ms 10588 KB Output is correct
16 Correct 2 ms 10596 KB Output is correct
17 Correct 1 ms 4952 KB Output is correct
18 Correct 1 ms 4700 KB Output is correct
19 Correct 1 ms 4700 KB Output is correct
20 Correct 2 ms 8540 KB Output is correct
21 Correct 2 ms 6748 KB Output is correct
22 Correct 1 ms 4444 KB Output is correct
23 Correct 2 ms 8540 KB Output is correct
24 Correct 2 ms 10588 KB Output is correct
25 Correct 2 ms 9052 KB Output is correct
26 Correct 2 ms 8796 KB Output is correct
27 Correct 1 ms 6500 KB Output is correct
28 Correct 1 ms 6540 KB Output is correct
29 Correct 1 ms 6492 KB Output is correct
30 Correct 1 ms 2404 KB Output is correct
31 Correct 2 ms 6492 KB Output is correct
32 Correct 2 ms 8784 KB Output is correct
33 Correct 2 ms 4696 KB Output is correct
34 Correct 2 ms 4696 KB Output is correct
35 Correct 1 ms 468 KB Output is correct
36 Correct 1 ms 4700 KB Output is correct
37 Correct 3 ms 12376 KB Output is correct
38 Correct 3 ms 14940 KB Output is correct
39 Correct 143 ms 15316 KB Output is correct
40 Correct 239 ms 27472 KB Output is correct
41 Correct 110 ms 15956 KB Output is correct
42 Correct 106 ms 10004 KB Output is correct
43 Correct 75 ms 16220 KB Output is correct
44 Correct 289 ms 22104 KB Output is correct
45 Correct 311 ms 17980 KB Output is correct
46 Correct 292 ms 22044 KB Output is correct
47 Correct 292 ms 21900 KB Output is correct
48 Correct 282 ms 23960 KB Output is correct
49 Correct 915 ms 54532 KB Output is correct
50 Correct 1053 ms 54560 KB Output is correct
51 Correct 1116 ms 54564 KB Output is correct
52 Correct 971 ms 54716 KB Output is correct
53 Correct 1084 ms 54716 KB Output is correct
54 Correct 925 ms 54500 KB Output is correct
55 Execution timed out 1531 ms 81700 KB Time limit exceeded
56 Halted 0 ms 0 KB -