제출 #202710

#제출 시각아이디문제언어결과실행 시간메모리
202710ZloyHR전선 연결 (IOI17_wiring)C++17
13 / 100
49 ms8040 KiB
//#include <bits/stdc++.h>
//using namespace std;
//typedef long long ll;
//typedef pair<ll,ll> pll;
//typedef pair<pll,ll> plll;
//typedef pair<pll,pll> ppll;
//typedef long double ld;
//
//#define all(x) (x).begin(), (x).end()
//#define rall(x) (x).rbegin(), (x).rend()
//#define fst first
//#define snd second
//#define ins insert
//#define pb push_back
//template< typename T,typename V>ostream &operator<< (ostream &out,const pair<T,V> x){ out << "{" << x.fst << " : " << x.snd << "}"; return out;}template< typename T>ostream &operator<< (ostream &out,const set<T> x){ for(auto &it : x){ out << it << " "; } return out;}template< typename T>ostream &operator<< (ostream &out,const multiset<T> x){ for(auto &it : x){ out << it << " "; } return out;}template< typename T,typename V>ostream &operator<< (ostream &out,const map<T,V> x){ for(auto &it : x){ out << "[" << it.fst << "]" << " = " << it.snd << "\n"; } return out;}template< typename T>ostream &operator<< (ostream &out,const vector<T> x){ for(int i = 0;i < x.size() - 1; ++i){ out << x[i] << " "; } out << x.back(); return out;}template< typename T>ostream &operator<< (ostream &out,const vector<vector<T> > x){ for(int i = 0;i < x.size() - 1; ++i){ out << "[" << i << "]" << " = {" << x[i] << "}\n"; } out << "[" << x.size() - 1 << "]" << " = {" << x.back() << "}\n"; return out;}
//
//const ll N = 1e6 + 5;
//const ll MOD = 1e9 + 7;
//const ll INF = 1e17;
//vector<pll> a;
//main(){
//    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//    //freopen(".in", "r", stdin);
//    //freopen(".out", "w", stdout);
//    ll n,m;
//    cin >> n >> m;
//    ll mxa = 0;
//    for(ll i = 0;i < n; ++i){
//        ll x;
//        cin >> x;
//        mxa = max(mxa,x);
//        a.pb({x,0});
//    }
//    ll mnb = INF;
//    for(ll i = 0;i < m; ++i){
//        ll x;
//        cin >> x;
//        mnb = min(mnb,x);
//        a.pb({x,1});
//    }
//    ll suma = 0,sumb = 0;
//    for(ll i = 0;i < n + m; ++i){
//        if(a[i].snd == 0){
//            suma += mxa - a[i].fst;
//        }else{
//            sumb += a[i].fst - mnb;
//        }
//    }
//    ll ans = suma + sumb + max(n,m) * (mnb - mxa);
//    cout << ans;
//    return 0;
//}
#include "wiring.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> plll;
typedef pair<pll,pll> ppll;
typedef long double ld;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fst first
#define snd second
#define ins insert
#define pb push_back
template< typename T,typename V>ostream &operator<< (ostream &out,const pair<T,V> x){ out << "{" << x.fst << " : " << x.snd << "}"; return out;}template< typename T>ostream &operator<< (ostream &out,const set<T> x){ for(auto &it : x){ out << it << " "; } return out;}template< typename T>ostream &operator<< (ostream &out,const multiset<T> x){ for(auto &it : x){ out << it << " "; } return out;}template< typename T,typename V>ostream &operator<< (ostream &out,const map<T,V> x){ for(auto &it : x){ out << "[" << it.fst << "]" << " = " << it.snd << "\n"; } return out;}template< typename T>ostream &operator<< (ostream &out,const vector<T> x){ for(int i = 0;i < x.size() - 1; ++i){ out << x[i] << " "; } out << x.back(); return out;}template< typename T>ostream &operator<< (ostream &out,const vector<vector<T> > x){ for(int i = 0;i < x.size() - 1; ++i){ out << "[" << i << "]" << " = {" << x[i] << "}\n"; } out << "[" << x.size() - 1 << "]" << " = {" << x.back() << "}\n"; return out;}

const ll N = 1e6 + 5;
const ll MOD = 1e9 + 7;
const ll INF = 1e17;
vector<pll> a;
long long min_total_length(std::vector<int> r, std::vector<int> b) {
    ll n = r.size(),m = b.size();
    ll mxa = 0;
    for(ll i = 0;i < n; ++i){
        ll x;
        x = r[i];
        mxa = max(mxa,x);
        a.pb({x,0});
    }
    ll mnb = INF;
    for(ll i = 0;i < m; ++i){
        ll x;
        x = b[i];
        mnb = min(mnb,x);
        a.pb({x,1});
    }
    ll suma = 0,sumb = 0;
    for(ll i = 0;i < n + m; ++i){
        if(a[i].snd == 0){
            suma += mxa - a[i].fst;
        }else{
            sumb += a[i].fst - mnb;
        }
    }
    ll ans = suma + sumb + max(n,m) * (mnb - mxa);
	return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...