#include "wiring.h"
#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::vector;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using std::string;
using pii = std::pair<ll,ll>;
#define rep(i,j,k) for(ll i=ll(j); i<ll(k); i++)
#define REP(i,j,k) for(ll i=ll(j); i<=ll(k); i++)
#define per(i,j,k) for(ll i=ll(j); i>=ll(k); i--)
#define ln "\n"
#define all(a) a.begin(), a.end()
#define mp std::make_pair
#define pb emplace_back
constexpr ll inf = (1ll<<60);
long long min_total_length(std::vector<int> r, std::vector<int> b) {
vector<pii> data;
for(auto el: r) data.pb(mp(el,0));
for(auto el: b) data.pb(mp(el,1));
sort(all(data));
ll N = r.size(), M = b.size();
ll ans = 0;
rep(i,0,N) ans -= r[i];
rep(i,0,M) ans += b[i];
if(N < M) ans -= r.back()*(M-N);
else ans += b[0]*(N-M);
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
3rd lines differ - on the 1st token, expected: '25859', found: '-4909' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
22 ms |
5600 KB |
Output is correct |
4 |
Correct |
22 ms |
7156 KB |
Output is correct |
5 |
Correct |
21 ms |
7132 KB |
Output is correct |
6 |
Correct |
28 ms |
7996 KB |
Output is correct |
7 |
Correct |
29 ms |
7964 KB |
Output is correct |
8 |
Correct |
31 ms |
7968 KB |
Output is correct |
9 |
Correct |
29 ms |
7968 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
3rd lines differ - on the 1st token, expected: '17703', found: '-19052' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
3rd lines differ - on the 1st token, expected: '27', found: '12' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
3rd lines differ - on the 1st token, expected: '25859', found: '-4909' |
2 |
Halted |
0 ms |
0 KB |
- |