/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 1.27 MiB
#2 Accepted 18ms 1.32 MiB
#3 Accepted 23ms 1.543 MiB
#4 Accepted 22ms 1.566 MiB
#5 Accepted 35ms 4.258 MiB
#6 Accepted 37ms 4.148 MiB

Code


/*

ওঁ ভূর্ভুবঃ স্বঃ তৎ সবিতুর্বরেণ্যং
ভর্গো দেবস্য ধীমহি।
ধিয়ো য়ো নঃ প্রচোদয়াৎ।।

*/

/*
"ওঁ মেধাং মে বরুনো দদাতি মেধাগ্নিঃ প্রজাপতিঃ।
মেধামিন্দ্রশ্চ বায়ুশ্চ মেধাং ধাতা দদাতি মে স্বাহা।। (যজুর্বেদ ৩২.১৫)

#অনুবাদ-   হে প্রকাশমান,প্রজা পালক প্রভু,আমি যেন মেধা প্রাপ্ত হই,মেধাবুদ্ধি ধারন করতে সক্ষম হই।
হে সর্বব্যপক পরমাত্মা,আমি যেন চরাচর জগতের সত্য- অসত্য বিচারের বিবেকযোগ্য বুদ্ধি ও মেধা প্রাপ্ত হই।
*/


#include<bits/stdc++.h>
#define ll long long
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define vi(a,n) for(int i=0;i<n;i++)cin>>a[i];
#define veci(v,a) vector<long long>v(a);
#define vo(a) for(int i=0;i<a.size();i++)cout<<a[i]<<" ";
#define mysort(a) sort(a.begin(),a.end());
#define for0 for(int i=0;i<n;i++)
#define for1 for(int i=1;i<=n;i++)
#define auto(v) for(auto u:v)cout<<u<<" ";
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define mxsz 10e9
#define rr return;
#define pi 3.141592653589793238
using namespace std;

bool isvalid(char a,char b){
    return ( a=='(' and b==')')or(a=='{' and b=='}')or(a=='[' and b==']');

}
ll gcd(ll a,ll b){
    if(b==0) return a;
    return gcd(b,a%b);
}

bool is_prime(ll n){
    if(n==1) return 0;
    for(int i=2;i*i<=n;i++){
        if(n%i==0){
            return 0;
        }
    }
    return 1;
}

int next_prime(long long n){

    while(!is_prime(++n));
    return n;

}

int ttra[1000];
bool tra(int n){

    for(int i=1;i<=500;i++){
        ttra[i]=(i*(i+1))/2;
        if(ttra[i]==n)
            return 1;
    }
    return 0;
}


vector<int>prime;
bool ar[3001];

void sieve(){
    int mx=3000;
//    for(int i=1;i<=mx;i++)ar[i]=1;
    ar[0] = ar[1] = true;
    for(int i=3;i*i<=mx;i+=2){
        if(!ar[i]){
            for(int j=i*i;j<=mx;j+=i){
                ar[j] = true;
            }
        }
    }
    for(int i=2;i<=mx;i++)
    if(!ar[i] && i%2!=0 || i==2)prime.push_back(i);

}

bool lucky(ll n){
    string s;

    s=to_string(n);
    for(auto u:s){
        if(u!='4' && u!='7'){
            return 0;
        }
    }
    return 1;
}

ll next_lucky(ll n){
    while(!lucky(n))++n;
    return n;
}

ll powof2(ll n){
    return n>0 && (n&(n-1))==0;
}


bool comparator(const pair<ll, ll>& a, pair<ll, ll>& b) {
    if (a.first != b.first) {
        // Sort in descending order based on the first element
        return a.first > b.first;
    } else {
        // If the first elements are equal, sort in ascending order based on the second element
        return a.second < b.second;
    }
}

const int M=998244353;

ll mod(ll a){
    return ((a%M+M)%M);
}
ll mod_add(ll a,ll b){
    return mod(mod(a)+mod(b));
}
ll mod_mul(ll a,ll b){
    return mod(mod(a)*mod(b));
}

ll fact(ll n){
    ll ans=1;
    for(int i=2;i<=n;i++){
        ans=(ans*i)%M;
    }
    return ans;
}

ll ori(ll x1,ll y1,ll x2,ll y2,ll x3,ll y3){
    ll val=(x3-x2)*(y2-y1)-(x2-x1)*(y3-y2);
    if(val>0){
        return 1;//clockwise
    }
    else if(val<0){
        return 2;//counter-clock-wise
    }
    else{
        return 0;//co-linear
    }
}

bool onSeg(pair<ll,ll> x1,pair<ll,ll> y1,pair<ll,ll> x2,pair<ll,ll> y2,pair<ll,ll> x3,pair<ll,ll> y3){
    return (x3<=max(x1,x2) && x3>=min(x1,x2) && y3<=max(y1,y2) && y3>=min(y1,y2));
}

bool intersect(ll a,ll b,ll c,ll d){
    //ll x1=a.ff,y1=a.ss,x2=b.ff,y2=b.ss,x3=c.ff,y3=c.ss,x4=d.ff,y4=d.ss;
    //ll o1=ori(x1,y1,x2,y2,x3,y3);
    //ll o2=ori(x1,y1,x2,y2,x4,y4);
    //ll o3=ori(x3,y3,x4,y4,x1,y1);
    //ll o4=ori(x3,y3,x4,y4,x2,y2);


   //if(o1!=o2 && o3!=o4){
   //    return 1;
   //}
   return 0;
}
vector<ll>dp(100005, -1);

void dnp(){
    dp[1]=1;
    for(int j=2;j<=999999;j++){
        string s=to_string(j);
        ll cnt=0;
        for(int i=0;i<s.size();i++){
            if(s[i]!='0'){
                cnt++;
            }
            if(cnt>1){
                break;
            }
        }
        if(cnt==1){
            dp[j]=1+dp[j-1];
        }
        else{
            dp[j]=dp[j-1];
        }
    }


}

const int N=1e7+9;
int cnt[N];
void solve()
{

    ll q,a,n,b,k,d,D,x,c,y;
    //n=3;
    cin>>n;

    //char c,c2='9',c3,c4;
    //cin>>c;
    vector<ll> v(n);

    //vector<ll> v2(n);
    vector<char>vc;
    //vector<pair<ll,ll>> v3(n);
    //vector<pair<int,int>> v4;

    set<ll>p;
    set<ll>p2;
    string s,t="01",s2,s3,s4="144";
    //cin>>s;
    //getline(cin,s);
    stack<char>st;
    stack<char>st2;
    map<ll,ll>m;

    map<ll,ll>m2;
    priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>>pq;
    deque<ll>dq;

    ll lim=1e7+5;
    bool f=true;


    ll ans=1,sum=0,sum2=0;

    ll cmin=LLONG_MAX,cmin2=INT_MAX,cmax=LLONG_MIN,cmax2=INT_MIN,cnt=0,cnt2=0;

    //vi(v,n);
    //v2=v;
    //vi(v2,q);
    //mysort(v2);

    for(int i=0;i<n;i++){
        cin>>v[i];
        pq.push({v[i],i});
    }
    cin>>q;
    for(int i=0;i<q;i++){
        ll x;
        cin>>x;
        auto ans=pq.top();
        cout<<ans.ss+1<<endl;
        pq.pop();
        pq.push({x,ans.ss});
    }

    //for(auto u:v)cout<<u<<" ";
    //cout << endl;

}
int main()
{
    optimize();
    //dnp();
    int t,c;
    //cin >> t;
    //for(int i=1;i<=t;i++)
    {
        //cout<<"Case "<<i<<": "<<endl;
        solve();
    }
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1086 KuZ the Position
Language
C++20 (G++ 13.2.0)
Submit At
2024-09-25 13:08:25
Judged At
2024-11-11 02:52:48
Judged By
Score
100
Total Time
37ms
Peak Memory
4.258 MiB