/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Wrong Answer 2ms 492.0 KiB
#3 Wrong Answer 2ms 540.0 KiB

Code

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
#define bug(a) cout<<#a<<" : "<<a<<endl;
#define bug2(a,b) cout<<#a<<" : "<<a<<"\t"<<#b<<" : "<<b<<endl;

signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int t=1;
    // cin>>t;
    int cs=1;
    while(t--){
        // cout<<"Case "<<cs++<<": \n";
        ll n,k;cin>>n>>k;
        vector<ll>v(n);
        int x;
        for(int i=0;i<n;i++){
            cin>>v[i]>>x;
        }
        ll ans=0;
        sort(v.begin(),v.end());
        for(ll i=0; i<n-1; i++)
        {
            ll x=abs(v[0]-v[i]);
            ll y=abs(v[n-1]-v[i]);
            ans += k*max(x,y);
        }
        cout<<ans<<endl;
        
    }
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1098 KuZ the Maximum spanning tree
Contest
LU IUJPC : Sylhet Division 2024
Language
C++17 (G++ 13.2.0)
Submit At
2024-12-09 06:14:44
Judged At
2024-12-09 06:14:44
Judged By
Score
1
Total Time
2ms
Peak Memory
540.0 KiB