Submission #1007280
Source Code Expand
#include <algorithm> #include <cassert> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <deque> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> #define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i)) #define rep(i,n) FOR(i,0,n) #define pb push_back #define eb emplace_back #define mp make_pair #define fst first #define snd second #define all(v) begin(v), end(v) #define debug(x) cerr<< #x <<": "<<x<<endl #define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<vector<int> > vvi; typedef vector<ll> vll; typedef vector<vector<ll> > vvll; template<class T> using vv=vector<vector< T > >; int main() { int w, h; scanf("%d %d", &w, &h); vi p(w+h); deque<vi> c(w+h, vi(2)); rep (i, w+h) { scanf("%d", &p[i]); c[i][0] = p[i]; c[i][1] = i; } sort(all(c)); ll cost = 0; int cw = 0; int ch = 0; rep (i, w+h) { vi edge = c[i]; ll num_edge; if (edge[1] < w) { num_edge = h + 1 - ch; cw += 1; } else { num_edge = w + 1 - cw; ch += 1; } cost += num_edge * edge[0]; } printf("%lld\n", cost); return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Gr-idian MST |
User | tspcx |
Language | C++14 (Clang 3.8.0) |
Score | 500 |
Code Size | 1467 Byte |
Status | AC |
Exec Time | 103 ms |
Memory | 12032 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 | 100 ms | 12032 KB |
02.txt | AC | 100 ms | 12032 KB |
03.txt | AC | 100 ms | 12032 KB |
04.txt | AC | 102 ms | 12032 KB |
05.txt | AC | 100 ms | 12032 KB |
06.txt | AC | 101 ms | 12032 KB |
07.txt | AC | 100 ms | 12032 KB |
08.txt | AC | 103 ms | 12032 KB |
09.txt | AC | 99 ms | 12032 KB |
10.txt | AC | 99 ms | 12032 KB |
11.txt | AC | 88 ms | 12032 KB |
12.txt | AC | 87 ms | 12032 KB |
13.txt | AC | 74 ms | 12032 KB |
14.txt | AC | 91 ms | 12032 KB |
15.txt | AC | 96 ms | 12032 KB |
16.txt | AC | 47 ms | 6144 KB |
17.txt | AC | 47 ms | 6272 KB |
18.txt | AC | 47 ms | 6144 KB |
19.txt | AC | 47 ms | 6144 KB |
20.txt | AC | 52 ms | 12032 KB |
21.txt | AC | 72 ms | 12032 KB |
22.txt | AC | 76 ms | 12032 KB |
23.txt | AC | 73 ms | 12032 KB |
24.txt | AC | 59 ms | 12032 KB |
25.txt | AC | 3 ms | 256 KB |
26.txt | AC | 3 ms | 256 KB |
27.txt | AC | 3 ms | 256 KB |
28.txt | AC | 3 ms | 256 KB |
s1.txt | AC | 3 ms | 256 KB |
s2.txt | AC | 3 ms | 256 KB |