답안 #884029

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
884029 2023-12-06T14:38:44 Z vjudge1 Bubble Sort 2 (JOI18_bubblesort2) C++17
0 / 100
1683 ms 904 KB
#include <bits/stdc++.h>

using namespace std;
vector<int>aib;
void update(int pos,int val,int n)
{
    int i=pos;
    while(i<=n)
    {
        aib[i]+=val;
        i+=(i&(-i));
    }
}
int get(int pos,int n)
{
    int i=pos,s=0;
    while(i>0)
    {
        s=s+aib[i];
        i-=(i&(-i));
    }
    return s;
}
vector<int> countScans(vector<int>A, vector<int>X, vector<int>V)
{

    int n=A.size(),q=X.size();
    vector<int>Aux(n);
    for(int i=0;i<n;i++)
    {
       // cin>>A[i];
        Aux[i]=A[i];
    }
    sort(Aux.begin(),Aux.end());
    for(int i=0;i<n;i++)
    {
        int l=-1,r=n-1;
        while(l<r-1)
        {
            int mid=(l+r)/2;
            if(A[i]<=Aux[mid])
            r=mid;
            else
            l=mid;
        }
        A[i]=r+1;
      //  cout<<A[i]<<' ';
    }

    vector<int>ans;
    for(int i=0;i<q;i++)
    {
        A[X[i]]=V[i];
        aib.assign(n+1,0);
        int ans1=0;//cout<<"asa";
        for(int j=0;j<n;j++)
        {
            ans1=max(ans1,get(n,n)-get(A[j],n));
           // cout<<"asa";
            update(A[j],1,n);
        }

        ans.push_back(ans1);
       // cout<<ans1<<'\n';
    }
    return ans;
}
/*int main()
{
    cin>>n>>q;
    vector<int>A(n);
    vector<int>Aux(n);
    vector<int>X(q);
    vector<int>V(q);
    for(int i=0;i<n;i++)
    {
        cin>>A[i];
        Aux[i]=A[i];
    }
    sort(Aux.begin(),Aux.end());
    for(int i=0;i<n;i++)
    {
        int l=-1,r=n-1;
        while(l<r-1)
        {
            int mid=(l+r)/2;
            if(A[i]<=Aux[mid])
            r=mid;
            else
            l=mid;
        }
        A[i]=r+1;
      //  cout<<A[i]<<' ';
    }
   // cout<<'\n';
    for(int i=0;i<q;i++)
    {
        cin>>X[i]>>V[i];
    }
   // countScans(A,X,V);
    return 0;
}*/
/*
6 1
5 6 2 3 4 1
3 3



*/
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1683 ms 904 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -