Submission #1820218
Source Code Expand
#include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <ctime> #include <iostream> #include <sstream> #include <functional> #include <map> #include <string> #include <cstring> #include <vector> #include <queue> #include <stack> #include <deque> #include <set> #include <list> #include <numeric> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<ll,ll> P; const double PI = 3.14159265358979323846; const double EPS = 1e-12; const ll INF = 1LL<<29; const ll mod = 1e9+7; #define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i)) #define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d)) #define all(v) (v).begin(), (v).end() #define pb(x) push_back(x) #define mp(x,y) make_pair((x),(y)) #define mset(m,v) memset((m),(v),sizeof(m)) #define chmin(X,Y) ((X)>(Y)?X=(Y),true:false) #define chmax(X,Y) ((X)<(Y)?X=(Y),true:false) #define fst first #define snd second #define UNIQUE(x) (x).erase(unique(all(x)),(x).end()) template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;} int main(){ ll w, h; cin>>w>>h; vector<ll> p(w), q(h); rep(i, w) cin>>p[i]; rep(i, h) cin>>q[i]; p.push_back(1e9); q.push_back(1e9); sort(all(p)); sort(all(q)); reverse(all(p)); reverse(all(q)); ll res = 0; while(w || h){ if(p[w]<q[h]) res += p[w--]*(h+1); else res += q[h--]*(w+1); } cout<<res<<endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Gr-idian MST |
User | Lepton |
Language | C++14 (GCC 5.4.1) |
Score | 500 |
Code Size | 1508 Byte |
Status | AC |
Exec Time | 98 ms |
Memory | 2560 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 500 / 500 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | s1.txt, s2.txt |
All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, s1.txt, s2.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | AC | 88 ms | 2560 KB |
02.txt | AC | 98 ms | 2560 KB |
03.txt | AC | 88 ms | 2560 KB |
04.txt | AC | 87 ms | 2560 KB |
05.txt | AC | 87 ms | 2560 KB |
06.txt | AC | 87 ms | 2560 KB |
07.txt | AC | 87 ms | 2560 KB |
08.txt | AC | 87 ms | 2560 KB |
09.txt | AC | 88 ms | 2560 KB |
10.txt | AC | 87 ms | 2560 KB |
11.txt | AC | 83 ms | 2560 KB |
12.txt | AC | 83 ms | 2560 KB |
13.txt | AC | 78 ms | 2560 KB |
14.txt | AC | 87 ms | 2560 KB |
15.txt | AC | 87 ms | 2560 KB |
16.txt | AC | 44 ms | 1792 KB |
17.txt | AC | 44 ms | 1792 KB |
18.txt | AC | 44 ms | 1792 KB |
19.txt | AC | 44 ms | 1792 KB |
20.txt | AC | 35 ms | 2560 KB |
21.txt | AC | 61 ms | 2560 KB |
22.txt | AC | 61 ms | 2560 KB |
23.txt | AC | 59 ms | 2560 KB |
24.txt | AC | 83 ms | 2560 KB |
25.txt | AC | 1 ms | 256 KB |
26.txt | AC | 1 ms | 256 KB |
27.txt | AC | 1 ms | 256 KB |
28.txt | AC | 1 ms | 256 KB |
s1.txt | AC | 1 ms | 256 KB |
s2.txt | AC | 1 ms | 256 KB |