Submission #1105326

# Submission time Handle Problem Language Result Execution time Memory
1105326 2024-10-26T07:35:37 Z Almonther Studentsko (COCI14_studentsko) C++
100 / 100
3 ms 4432 KB
#include <bits/stdc++.h>

#define suiii ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define co cout<<
//#pragma GCC optimize("O3,Ofast,unroll-loops")
//#pragma GCC target("avx2,sse3,sse4,avx")
using namespace std;
//stuff
const ll N=exp2(ceil(log2(1e5)));
ll n,k,mx;
ll arr[1000001],tre[N*4];
pair<ll,ll>arr1[1000001];
ll que(ll l,ll r,ll i,ll lq,ll rq){
    if(l>rq||r<lq) return 0;
    if(l>=lq&&r<=rq) return tre[i];
    ll mid=(l+r)/2;
    return max(que(l,mid,i*2,lq,rq),que(mid+1,r,i*2+1,lq,rq));
}
void upd(ll x,ll val){
    x+=N;
    tre[x]=max(tre[x],val);
    x/=2;
    while(x) tre[x]=max(tre[x*2],tre[x*2+1]),x/=2;
}
void solve(){
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>arr[i];
        arr1[i]={arr[i],i};
    }
    sort(arr1,arr1+n);
    for(int i=0;i<n;i++) arr[arr1[i].second]=i/k;
    for(int i=0;i<n;i++) upd(arr[i],que(0,N-1,1,0,arr[i])+1);
    co n-tre[1];
}
int main()
{
    suiii
    int _=1;
    // cin>>_;
    while(_--) solve();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 4432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4432 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2640 KB Output is correct
2 Correct 2 ms 2640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2640 KB Output is correct
2 Correct 3 ms 2640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2640 KB Output is correct
2 Correct 2 ms 2640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2640 KB Output is correct
2 Correct 2 ms 2640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2640 KB Output is correct
2 Correct 2 ms 2640 KB Output is correct