Aayuushh19's blog

By Aayuushh19, history, 20 months ago, In English
void solve(){
    ll n;cin>>n;
    ll flag =0;
    vll b(n+2);
    FOR(i,0,n+2){
    	cin>>b[i];
    }
    ll mx = *max_element(all(b));
    sort(b.begin(),b.end());
    ll sum = accumulate(all(b),0);
    sum = sum-b[n+1];
    ll s2 = sum-b[n];
    dbg(sum);
    dbg(s2);
    ll x=-1;
    for(ll i=0;i<n+1;i++){
        if(sum-b[i]==mx){
            x=i;
            break;
        }
    }
    if(x==-1){
        ll s=0;
        for(ll i=0;i<n;i++){
            s+=b[i];
        }
        dbg(s);
        if(s==b[n]){
            flag=1;
            for(ll i=0;i<n;i++){
                cout<<b[i]<<" ";
            }
            cout<<endl;
        }
    }
    else{
        flag =1;
        for(ll i=0;i<n+1;i++){
            if(i!=x){
                cout<<b[i]<<" ";
            }
        }
        cout<<endl;
    }
    if(flag==0) cout<<-1<<endl;
   

}

https://codeforces.com/contest/1512/problem/D

Full text and comments »

  • Vote: I like it
  • -18
  • Vote: I do not like it

By Aayuushh19, history, 20 months ago, In English

void solve(){ ll n;cin>>n; vll b(n+2); FOR(i,0,n+2){ cin>>b[i]; } ll mx = *max_element(all(b)); sort(b.rbegin(),b.rend());

vll a;
ll c=0;
FOR(i,1,n+3){
    if(b[i]<=mx and c<n){
       a.pb(b[i]);
       mx-=b[i];
        c++;
    }
}
// dbg(a);
if(sz(a)!=n){
    sort(all(b));
    dbg(b);
    ll m = *max_element(all(b));
    vll temp;
    FOR(i,0,n){
        temp.pb(b[i]);
    }
    dbg(temp);
    if(accumulate(all(temp),0)!=m){
        cout<<-1<<endl;
        return;
    }
    for(auto i:temp){
        cout<<i<<" ";
    }
    cout<<endl;
}
else{
    for(auto i:a){
        cout<<i<<" ";
    }
    cout<<endl;
}

}

https://codeforces.com/problemset/problem/1512/D

Why this code is not working in online judge but working in my pc.

Full text and comments »

  • Vote: I like it
  • -5
  • Vote: I do not like it

By Aayuushh19, history, 20 months ago, In English

https://codeforces.com/contest/1715/problem/A

void solve(){ ll n,m;cin>>n>>m; if(n==1 and m==1){ cout<<0<<endl; return; } ll a = m-1; ll b = n-1; ll c = min(n,m)-1; cout<<a+b+c+1<<endl;

}

Full text and comments »

  • Vote: I like it
  • -24
  • Vote: I do not like it

By Aayuushh19, history, 20 months ago, In English

https://codeforces.com/problemset/problem/1557/A

void solve(){ ll n;cin>>n; vll arr(n); FOR(i,0,n)cin>>arr[i]; double m=*max_element(all(arr)); double sum = accumulate(all(arr),0); sum=sum-m; double avg = sum/(n-1);

cout<<fixed<<setprecision(10)<<m+avg<<endl;

}

Full text and comments »

  • Vote: I like it
  • -11
  • Vote: I do not like it

By Aayuushh19, history, 20 months ago, In English

void solve(){ ll a,b,c,d;cin>>a>>b>>c>>d; ll a1=a/b; ll c1=c/d; if(a1==c1){ cout<<0<<endl; } else if(a1%c1==0){ cout<<1<<endl; } else if(c1%a1==0){ cout<<1<<endl; } else cout<<2<<endl;

}

why I am getting TLE in this Program

https://codeforces.com/contest/1720/problem/A

Full text and comments »

  • Vote: I like it
  • -1
  • Vote: I do not like it

By Aayuushh19, history, 2 years ago, In English

completed 10 days of streak

Full text and comments »

  • Vote: I like it
  • -8
  • Vote: I do not like it