Изменения рейтингов за последние раунды временно удалены. Скоро они будут возвращены. ×

Блог пользователя bitthal04

Автор bitthal04, история, 7 месяцев назад, По-английски

Just want to get the idea if and who are coming?

Полный текст и комментарии »

  • Проголосовать: нравится
  • +3
  • Проголосовать: не нравится

Автор bitthal04, история, 7 месяцев назад, По-английски

I was participating in meta hacker cup as practice round is going on now. But for 2/3 questions for which the submissions i made i got presentation error. And at this point i am not able to figure out much what were the difference between them. So can someone tell me how to handle this so i don't mess up because of this.(As the contest is still going on i am not sure if i should share my code here but if someone wants i can share it to him/her personally).

Edit: One thing which i forgot to mention i solved some problems from last year as well and all those question which had single line output like "Case #1: 5" these tend to work fine but only those which had multiple lines output seem to fail(Not sure if that's the correct reasoning or not).

Полный текст и комментарии »

  • Проголосовать: нравится
  • +1
  • Проголосовать: не нравится

Автор bitthal04, история, 8 месяцев назад, По-английски

https://mirror.codeforces.com/contest/2031/problem/D Problem link.

ll n;
cin>>n;

ll arr[n];
vector<ll> gret(n);
map <ll,ll,greater<ll>> mp;

for(int i=0;i<n;i++){
    cin>>arr[i];
    gret[i]=arr[i];

    if(i>0)
    gret[i]=max(gret[i],gret[i-1]);

    if(mp.find(arr[i])==mp.end())
    mp[arr[i]]=i;
}

auto it=mp.begin();

ll cnt=0;
ll mi=it->first;
ll ans[n];

int i=it->second,la=n;

while(cnt<n){
    int q=i;
    for(;i<la;i++){
        ans[i]=it->first;
        mi=min(mi,arr[i]);
        cnt++;
    }
    la=q;

    if(cnt==n)
    break;

    int k=upper_bound(gret.begin(),gret.end(),mi)-gret.begin();
    if(mi==it->first || gret[k]==it->first){
        it=mp.find(gret[la-1]);
        i=it->second;
    }
    else{
        i=k;
    }
}

for(int j=0;j<n;j++)
cout<<ans[j]<<" ";
cout<<endl;

This is the code. I am not able to get why I am getting TLE when the code complexity should be O(nlogn) which should be acceptable?

Полный текст и комментарии »

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится