Submission #3247484
Source Code Expand
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <cmath> #include <cstdio> #include <functional> #include <numeric> #include <stack> #include <queue> #include <map> #include <set> #include <utility> #include <sstream> #include <complex> #include <fstream> #include <bitset> #include <time.h> #include <tuple> #include <iomanip> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<ll, ll> P; typedef vector<ll> V; typedef complex<double> Point; #define PI acos(-1.0) #define EPS 1e-10 const ll INF = 1e12; const ll MOD = 1e9 + 7; #define FOR(i,a,b) for(int i=(a);i<(b);i++) #define rep(i,N) for(int i=0;i<(N);i++) #define ALL(s) (s).begin(),(s).end() #define EQ(a,b) (abs((a)-(b))<EPS) #define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) ) #define fi first #define se second #define N_SIZE (1LL << 20) #define NIL -1 ll sq(ll num) { return num*num; } ll mod_pow(ll x, ll n) { if (n == 0)return 1; if (n == 1)return x%MOD; ll res = sq(mod_pow(x, n / 2)); res %= MOD; if (n % 2 == 1) { res *= x; res %= MOD; } return res; } ll mod_add(ll a, ll b) { return (a + b) % MOD; } ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; } ll mod_mul(ll a, ll b) { return a*b % MOD; } int h,w; int main(){ cin >> h >> w; vector<P> p; rep(i,h){ ll num; cin >> num; p.push_back(P(num,0)); } rep(i,w){ ll num; cin >> num; p.push_back(P(num,1)); } sort(ALL(p)); ll cnt[2] = {}; ll def = 0; ll prev = p[0].second; ll ans = 0; rep(i,p.size()){ ll num = p[i].first; bool now = p[i].second; if(prev != now)def = cnt[prev]; cnt[now]++; prev = now; if(now == 0)num *= (w+1-def); else num *= (h+1-def); // cout << "!"<< num << endl; ans += num; prev = now; } cout << ans << endl; }
Submission Info
Submission Time | |
---|---|
Task | C - Gr-idian MST |
User | jimmy |
Language | C++14 (GCC 5.4.1) |
Score | 500 |
Code Size | 1909 Byte |
Status | AC |
Exec Time | 100 ms |
Memory | 6512 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 | 4464 KB |
02.txt | AC | 92 ms | 4976 KB |
03.txt | AC | 91 ms | 6256 KB |
04.txt | AC | 91 ms | 6384 KB |
05.txt | AC | 91 ms | 6000 KB |
06.txt | AC | 91 ms | 6000 KB |
07.txt | AC | 91 ms | 6000 KB |
08.txt | AC | 92 ms | 6256 KB |
09.txt | AC | 91 ms | 5616 KB |
10.txt | AC | 91 ms | 4720 KB |
11.txt | AC | 90 ms | 4464 KB |
12.txt | AC | 100 ms | 6256 KB |
13.txt | AC | 94 ms | 4464 KB |
14.txt | AC | 90 ms | 4592 KB |
15.txt | AC | 91 ms | 6256 KB |
16.txt | AC | 46 ms | 2420 KB |
17.txt | AC | 45 ms | 2420 KB |
18.txt | AC | 46 ms | 2420 KB |
19.txt | AC | 45 ms | 2420 KB |
20.txt | AC | 39 ms | 5616 KB |
21.txt | AC | 64 ms | 4592 KB |
22.txt | AC | 64 ms | 5104 KB |
23.txt | AC | 85 ms | 6512 KB |
24.txt | AC | 87 ms | 5872 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 |