Submission #836897

# Submission time Handle Problem Language Result Execution time Memory
836897 2023-08-24T16:57:14 Z groshi Money (IZhO17_money) C++17
0 / 100
1 ms 340 KB
#include<bits/stdc++.h>
#define int long long
using namespace std;
int pot=1;
int drzewo[3000000];
int lazy[3000000];
int t[3000000];
void propaguj(int x,int l,int r)
{
    drzewo[x*2]+=lazy[x]*(r-l+1)/2;
    drzewo[x*2+1]+=lazy[x]*(r-l+1)/2;
    lazy[x*2]+=lazy[x];
    lazy[x*2+1]+=lazy[x];
    lazy[x]=0;
}
int suma(int x,int l,int r,int a,int b)
{
    if(r<a || l>b)
        return 0;
    propaguj(x,l,r);
    if(a<=l && r<=b)
        return drzewo[x];
    int mid=(l+r)/2;
    int L=suma(x*2,l,mid,a,b);
    int R=suma(x*2+1,mid+1,r,a,b);
    drzewo[x]=drzewo[x*2]+drzewo[x*2+1];
    return L+R;
}
void dodaj(int x,int l,int r,int a,int b)
{
    if(r<a || l>b)
        return;
    propaguj(x,l,r);
    if(a<=l && r<=b)
    {
        drzewo[x]+=(r-l+1);
        lazy[x]++;
        return;
    }
    int mid=(l+r)/2;
    dodaj(x*2,l,mid,a,b);
    dodaj(x*2+1,mid+1,r,a,b);
    drzewo[x]=drzewo[x*2]+drzewo[x*2+1];
}
int32_t main()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    int n;
    cin>>n;
    while(pot<=n)
        pot*=2;
    pot--;
    for(int i=1;i<=n;i++)
        cin>>t[i];
    int wynik=0;
    for(int i=1;i<=n;i++)
    {
        int j=i;
        while(j+1<=n && t[j+1]>t[j] && suma(1,pot+1,pot*2+1,t[i]+pot,pot+t[j+1])==0)
            j++;
        i=j;
        wynik++;
        dodaj(1,pot+1,pot*2,t[i]+pot,pot+t[j]);
    }
    cout<<wynik;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -