Submission #1247505
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()
#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second
#define x1 gray_cat_x1
#define y1 gray_cat_y1
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
#define file "cycle"
const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const int MAXN = 2e5 + 5;
vector<pii> pp;
int cnt[2], lim[2];
void solve(){
scanf("%d%d", &lim[0], &lim[1]);
REP(i, 0, 2){
REP(j, 0, lim[i]){
int a;
scanf("%d", &a);
pp.pb(mp(a, i));
}
}
SORT(pp);
ll ans = 0ll;
//ll cnt = (ll)lim[0] * (ll)lim[1];
REP(i, 0, SZ(pp)){
int ind = pp[i]._2;
/*ll add = 0ll;
if (!cnt[ind ^ 1]){
add = lim[ind ^ 1];
} else {
add = lim[ind ^ 1] - max(0, cnt[ind ^ 1] - 1);
}*/
ll add = lim[ind ^ 1] - cnt[ind ^ 1] + 1;
//cout << add << " " << add * pp[i]._1 << endl;
ans += add * pp[i]._1;
cnt[ind]++;
}
printf("%lld\n", ans);
}
int main(){
//freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
int t = 1;
//cin >> t;
while(t--){
solve();
}
}
Submission Info
Submission Time |
|
Task |
C - Gr-idian MST |
User |
Timur_Sitdikov |
Language |
C++14 (GCC 5.4.1) |
Score |
500 |
Code Size |
1617 Byte |
Status |
AC |
Exec Time |
41 ms |
Memory |
2420 KB |
Compile Error
./Main.cpp: In function ‘void solve()’:
./Main.cpp:41:33: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d", &lim[0], &lim[1]);
^
./Main.cpp:45:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &a);
^
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 |
40 ms |
2420 KB |
02.txt |
AC |
40 ms |
2420 KB |
03.txt |
AC |
39 ms |
2420 KB |
04.txt |
AC |
40 ms |
2420 KB |
05.txt |
AC |
40 ms |
2420 KB |
06.txt |
AC |
40 ms |
2420 KB |
07.txt |
AC |
40 ms |
2420 KB |
08.txt |
AC |
40 ms |
2420 KB |
09.txt |
AC |
40 ms |
2420 KB |
10.txt |
AC |
40 ms |
2420 KB |
11.txt |
AC |
38 ms |
2420 KB |
12.txt |
AC |
38 ms |
2420 KB |
13.txt |
AC |
41 ms |
2420 KB |
14.txt |
AC |
39 ms |
2420 KB |
15.txt |
AC |
40 ms |
2420 KB |
16.txt |
AC |
20 ms |
1400 KB |
17.txt |
AC |
20 ms |
1400 KB |
18.txt |
AC |
20 ms |
1400 KB |
19.txt |
AC |
20 ms |
1400 KB |
20.txt |
AC |
22 ms |
2420 KB |
21.txt |
AC |
30 ms |
2420 KB |
22.txt |
AC |
31 ms |
2420 KB |
23.txt |
AC |
39 ms |
2420 KB |
24.txt |
AC |
30 ms |
2420 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 |