Submission #63514223
Source Code Expand
/*
Author: rnishiura
Date: 25-03-08
Description: template
*/
// #define ATCODER_
#include <bits/stdc++.h>
#ifdef ATCODER_
#include <atcoder/all>
#endif
#define _GLIBCXX_DEBUG
#define rep(x, n) for(ll x=0; x<n; x++)
#define repi(x, a, b) for(ll x=a; x<b; x++)
#define rrep(x, n) for(ll x=n-1; x>=0; x--)
#define rrepi(x, a, b) for(ll x=b-1; x>=a; x--)
#define SQ(z) ((z)*(z))
#define contains(x, a) ((a).find(x) != (a).end())
#define all(a) (a).begin(), (a).end()
#define sum(a) (accumulate(all(a), 0LL))
#define mini(a) (min_element(all(a)) - (a).begin())
#define maxi(a) (max_element(all(a)) - (a).begin())
#define mine(a) (*min_element(all(a)))
#define maxe(a) (*max_element(all(a)))
#define lowb(x, a) (lower_bound(all(a), (x)) - (a).begin())
#define uppb(x, a) (upper_bound(all(a), (x)) - (a).begin())
#define divl(n, m) ((n+m)/(m))
#define divle(n, m) ((n+m-1)/(m))
#define divse(n, m) ((n)/(m))
#define divs(n, m) ((n-1)/(m))
#define bstoi(s) stoi((s), nullptr, 2)
#define MOD 998244353
#define PI 3.14159265358979323846
#define inf (1LL << 61)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define POS fi
#define COST se
#define endl '\n'
#define unordered_multiset multiset
#define TRUE 1
#define FALSE 0
#define VNAME(v) #v
#define GET_MACRO(_1,_2,_3, NAME,...) NAME
#define print(...) GET_MACRO(__VA_ARGS__, print3, print2, print1)(__VA_ARGS__)
#define debug(...) GET_MACRO(__VA_ARGS__, debug3, debug2, debug1)(__VA_ARGS__)
#define print1(z) { cout << (z) << endl; }
#define print2(y, z) { cout << (y) << ' '; print1(z); }
#define print3(x, y, z) { cout << (x) << ' '; print2(y, z); }
#define debug1(z) { if(DEBUG) { print(VNAME(z)); print(z); } }
#define debug2(y, z) { if(DEBUG) { print(VNAME(y), VNAME(z)); print(y, z); } }
#define debug3(x, y, z) { if(DEBUG) { print(VNAME(x), VNAME(y), VNAME(z)); print(x, y, z); } }
#ifdef ATCODER_
using namespace atcoder;
using mint = modint998244353;
#endif
using namespace std;
using ll = long long;
using v = vector<ll>;
using vv = vector<v>;
using vp = vector<pair<ll, ll>>;
using vvp = vector<vp>;
ll modinv(ll x) {
ll r=1, m=MOD-2;
x %= MOD;
while(m) {
if(m%2) r = r*x%MOD;
x = x*x%MOD;
m >>= 1;
}
return r;
}
struct mint {
unsigned long long val;
mint operator+(mint b) {
return mint{(this->val+b.val)%MOD};
}
mint operator-(mint b) {
return mint{(MOD+this->val-b.val)%MOD};
}
mint operator*(mint b) {
return mint{this->val*b.val%MOD};
}
mint operator/(mint b) {
return mint{this->val*modinv(b.val)%MOD};
}
void operator+=(mint b) { *this=*this+b; }
void operator-=(mint b) { *this=*this-b; }
void operator*=(mint b) { *this=*this*b; }
void operator/=(mint b) { *this=*this/b; }
};
template<typename T, typename U> istream& operator>>(istream& is, pair<T, U> &p){is >> p.first >> p.second; return is;}
template<typename T, typename U> ostream& operator<<(ostream& os, pair<T, U> p){os << p.first << ' ' << p.second; return os;}
template<typename T> vector<T>& operator-- (vector<T> &v){for (auto& i : v) --i; return v;}
template<typename T> vector<T>& operator++ (vector<T> &v){for (auto& i : v) ++i; return v;}
template<typename T> istream& operator>>(istream& is, vector<T> &v){for (auto& i : v) is >> i; return is;}
// template<typename T> ostream& operator<<(ostream& os, vector<bool> v){for (auto i : v) os << (i ? 'T' : 'F') << ' '; return os;}
template<typename T> ostream& operator<<(ostream& os, vector<T> v){for (auto i : v) os << i << ' '; return os;}
template<typename T> ostream& operator<<(ostream& os, vector<vector<T>> v){for (auto& i : v) os << i << endl; return os;}
template<typename T, typename U> pair<T,U>& operator-- (pair<T, U> &p){--p.first; --p.second; return p;}
template<typename T, typename U> pair<T,U>& operator++ (pair<T, U> &p){++p.first; ++p.second; return p;}
template<typename T, typename U> pair<T,U> operator-(pair<T,U> a, pair<T,U> b){return mp(a.first-b.first, a.second-b.second);}
template<typename T, typename U> pair<T,U> operator+(pair<T,U> a, pair<T,U> b){return mp(a.first+b.first, a.second+b.second);}
template<typename T, typename U> pair<T,T> operator*(pair<T,T> a, U b){return mp(a.first*b , a.second*b);}
template<typename T, typename U> pair<T,T> operator/(pair<T,T> a, U b){return mp(a.first/b , a.second/b);}
template<typename T, typename U> pair<T,T> operator%(pair<T,T> a, U b){return mp(a.first%b , a.second%b);}
template<typename T, typename U> void umin(T& a, U b){if (a > b) a = b;}
template<typename T, typename U> void umax(T& a, U b){if (a < b) a = b;}
const string DEBUG_MESSAGE = "DEBUG MODE IS ON";
// const int DEBUG = TRUE;
const int DEBUG = FALSE;
void solve() {
ll n, m; cin >> n >> m;
v B(n), W(m); cin >> B >> W;
sort(all(B));
reverse(all(B));
sort(all(W));
reverse(all(W));
ll r=0;
rep(i, n) {
if(i < m) {
r += max(0ll, max(B[i]+W[i], B[i]));
} else {
r += max(0ll, B[i]);
}
}
print(r);
}
int main(void) {
debug(DEBUG_MESSAGE);
cin.tie(nullptr); ios::sync_with_stdio(false);
ll t = 1; // cin >> t;
rep(i, t) solve();
debug(DEBUG_MESSAGE);
}
Submission Info
| Submission Time |
|
| Task |
C - Buy Balls |
| User |
rnishiura |
| Language |
C++ 23 (gcc 12.2) |
| Score |
300 |
| Code Size |
5586 Byte |
| Status |
AC |
| Exec Time |
50 ms |
| Memory |
6352 KiB |
Judge Result
| Set Name |
Sample |
All |
| Score / Max Score |
0 / 0 |
300 / 300 |
| Status |
|
|
| Set Name |
Test Cases |
| Sample |
00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt |
| All |
00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_test_00.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt, 01_test_11.txt, 01_test_12.txt, 01_test_13.txt, 01_test_14.txt, 01_test_15.txt, 01_test_16.txt, 01_test_17.txt, 01_test_18.txt, 01_test_19.txt, 01_test_20.txt, 01_test_21.txt, 01_test_22.txt, 01_test_23.txt, 01_test_24.txt, 01_test_25.txt, 01_test_26.txt, 01_test_27.txt, 01_test_28.txt, 01_test_29.txt, 01_test_30.txt, 01_test_31.txt, 01_test_32.txt, 01_test_33.txt, 01_test_34.txt, 01_test_35.txt, 01_test_36.txt, 01_test_37.txt, 01_test_38.txt, 01_test_39.txt, 01_test_40.txt, 01_test_41.txt, 01_test_42.txt, 01_test_43.txt, 01_test_44.txt, 01_test_45.txt |
| Case Name |
Status |
Exec Time |
Memory |
| 00_sample_00.txt |
AC |
1 ms |
3420 KiB |
| 00_sample_01.txt |
AC |
1 ms |
3556 KiB |
| 00_sample_02.txt |
AC |
1 ms |
3420 KiB |
| 01_test_00.txt |
AC |
1 ms |
3404 KiB |
| 01_test_01.txt |
AC |
1 ms |
3428 KiB |
| 01_test_02.txt |
AC |
1 ms |
3432 KiB |
| 01_test_03.txt |
AC |
25 ms |
4576 KiB |
| 01_test_04.txt |
AC |
17 ms |
4172 KiB |
| 01_test_05.txt |
AC |
15 ms |
4128 KiB |
| 01_test_06.txt |
AC |
49 ms |
6340 KiB |
| 01_test_07.txt |
AC |
49 ms |
6220 KiB |
| 01_test_08.txt |
AC |
49 ms |
6160 KiB |
| 01_test_09.txt |
AC |
49 ms |
6184 KiB |
| 01_test_10.txt |
AC |
49 ms |
6252 KiB |
| 01_test_11.txt |
AC |
50 ms |
6168 KiB |
| 01_test_12.txt |
AC |
49 ms |
6276 KiB |
| 01_test_13.txt |
AC |
50 ms |
6240 KiB |
| 01_test_14.txt |
AC |
50 ms |
6216 KiB |
| 01_test_15.txt |
AC |
43 ms |
5936 KiB |
| 01_test_16.txt |
AC |
48 ms |
6288 KiB |
| 01_test_17.txt |
AC |
41 ms |
5656 KiB |
| 01_test_18.txt |
AC |
49 ms |
6188 KiB |
| 01_test_19.txt |
AC |
45 ms |
6004 KiB |
| 01_test_20.txt |
AC |
48 ms |
6256 KiB |
| 01_test_21.txt |
AC |
42 ms |
5740 KiB |
| 01_test_22.txt |
AC |
48 ms |
6352 KiB |
| 01_test_23.txt |
AC |
39 ms |
5764 KiB |
| 01_test_24.txt |
AC |
48 ms |
6252 KiB |
| 01_test_25.txt |
AC |
39 ms |
5392 KiB |
| 01_test_26.txt |
AC |
49 ms |
6188 KiB |
| 01_test_27.txt |
AC |
42 ms |
5628 KiB |
| 01_test_28.txt |
AC |
47 ms |
6268 KiB |
| 01_test_29.txt |
AC |
41 ms |
5656 KiB |
| 01_test_30.txt |
AC |
48 ms |
6164 KiB |
| 01_test_31.txt |
AC |
34 ms |
5488 KiB |
| 01_test_32.txt |
AC |
47 ms |
6248 KiB |
| 01_test_33.txt |
AC |
36 ms |
5740 KiB |
| 01_test_34.txt |
AC |
45 ms |
6160 KiB |
| 01_test_35.txt |
AC |
38 ms |
5708 KiB |
| 01_test_36.txt |
AC |
47 ms |
6276 KiB |
| 01_test_37.txt |
AC |
31 ms |
5224 KiB |
| 01_test_38.txt |
AC |
48 ms |
6240 KiB |
| 01_test_39.txt |
AC |
35 ms |
5444 KiB |
| 01_test_40.txt |
AC |
47 ms |
6216 KiB |
| 01_test_41.txt |
AC |
34 ms |
5460 KiB |
| 01_test_42.txt |
AC |
48 ms |
6200 KiB |
| 01_test_43.txt |
AC |
1 ms |
3420 KiB |
| 01_test_44.txt |
AC |
25 ms |
4656 KiB |
| 01_test_45.txt |
AC |
25 ms |
4576 KiB |