Submission #1349135
Source Code Expand
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
ll p[100010], q[100010], pp[100010];
signed main(void)
{
int w, h;
cin >> w >> h;
REP(i, w) cin >> q[i];
REP(i, h) cin >> p[i];
p[h] = 0;
sort(p, p+h+1);
REP(i, h+1) pp[i] = p[i];
//pの累積和
FOR(i, 1, h+1) pp[i] += pp[i-1];
//REP(i, h+1) cout << p[i] << " "; cout << endl;
//REP(i, h+1) cout << pp[i] << " "; cout << endl;
ll ans = pp[h];
REP(i, w) {
int itr = upper_bound(p, p+h+1, q[i]) - p - 1;
ans += pp[itr] + (h+1-itr)*q[i];
//cout << itr << " " << ans << endl;
}
cout << ans << endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
C - Gr-idian MST |
User |
ferin_tech |
Language |
C++14 (GCC 5.4.1) |
Score |
500 |
Code Size |
1185 Byte |
Status |
AC |
Exec Time |
96 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 |
91 ms |
2560 KB |
02.txt |
AC |
91 ms |
2560 KB |
03.txt |
AC |
92 ms |
2560 KB |
04.txt |
AC |
91 ms |
2560 KB |
05.txt |
AC |
92 ms |
2560 KB |
06.txt |
AC |
91 ms |
2560 KB |
07.txt |
AC |
91 ms |
2560 KB |
08.txt |
AC |
91 ms |
2560 KB |
09.txt |
AC |
92 ms |
2560 KB |
10.txt |
AC |
96 ms |
2560 KB |
11.txt |
AC |
85 ms |
2560 KB |
12.txt |
AC |
93 ms |
2560 KB |
13.txt |
AC |
86 ms |
2560 KB |
14.txt |
AC |
82 ms |
2560 KB |
15.txt |
AC |
83 ms |
2560 KB |
16.txt |
AC |
44 ms |
1792 KB |
17.txt |
AC |
38 ms |
1024 KB |
18.txt |
AC |
44 ms |
1792 KB |
19.txt |
AC |
38 ms |
1024 KB |
20.txt |
AC |
37 ms |
2560 KB |
21.txt |
AC |
61 ms |
2560 KB |
22.txt |
AC |
58 ms |
2560 KB |
23.txt |
AC |
70 ms |
2560 KB |
24.txt |
AC |
85 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 |