#include<bits/stdc++.h>
#include<random>
using namespace std;
template<typename T> void _do(T x){cerr<<x<<"\n";}
template<typename T,typename ...U> void _do(T x,U ...y){cerr<<x<<", ";_do(y...);}
#define dbg(...) cerr<<#__VA_ARGS__<<" = ";_do(__VA_ARGS__);
#define float double
#define ss(n) fixed<<setprecision(n)
#define ll long long
#define int ll
#define IO ios::sync_with_stdio(false);cin.tie(0);
#define ld long double
#define pb push_back
#define pii pair<int,int>
#define rep(i,a) for(int i=1;i<=a;i++)
#define rep0(i,a) for(int i=0;i<a;i++)
#define F first
#define S second
#define uni(a) a.resize(distance(a.begin(),unique(a.begin(),a.end())));
#define unisort(a) sort(a.begin(),a.end()); uni(a);
ll gcd(ll a,ll b){if(b==0) return a; return gcd(b,a%b);}
const ld pi=3.14159265358979323846264338327950288419716939931;
const int lar=3e18;
const int mol1=1e9+7;
const int mol2=998244353;
const int MX=3e5;
void solve()
{
int n,m;
cin>>n>>m;
int a[n+1],b[n+1];
rep(i,n) cin>>a[i];
rep(i,n) cin>>b[i];
priority_queue<pair<int,int>,vector<pair<int,int>>,greater<>>now;
rep(i,n) now.push({0,i});
rep(i,m){
int vis[n+1]={0};
rep(j,n){
pair<int,int>kk=now.top();
now.pop();
if(vis[kk.S]==0){
kk.F+=max(a[kk.S],b[kk.S]);
vis[kk.S]=1;
}
else {
kk.F+=b[kk.S];
}
now.push(kk);
}
}
cout<<now.top().F<<"\n";
}
signed main()
{
IO
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
320 KB |
Output is correct |
4 |
Correct |
0 ms |
324 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
2 ms |
596 KB |
Output is correct |
11 |
Correct |
94 ms |
13380 KB |
Output is correct |
12 |
Correct |
93 ms |
13460 KB |
Output is correct |
13 |
Correct |
88 ms |
13572 KB |
Output is correct |
14 |
Correct |
87 ms |
13476 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
67 ms |
13592 KB |
Output is correct |
17 |
Correct |
125 ms |
13500 KB |
Output is correct |
18 |
Correct |
93 ms |
13652 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
67 ms |
13592 KB |
Output is correct |
3 |
Correct |
125 ms |
13500 KB |
Output is correct |
4 |
Correct |
93 ms |
13652 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
66 ms |
6956 KB |
Output is correct |
14 |
Correct |
51 ms |
4480 KB |
Output is correct |
15 |
Correct |
40 ms |
3684 KB |
Output is correct |
16 |
Correct |
48 ms |
2908 KB |
Output is correct |
17 |
Correct |
15 ms |
340 KB |
Output is correct |
18 |
Correct |
10 ms |
212 KB |
Output is correct |
19 |
Correct |
7 ms |
316 KB |
Output is correct |
20 |
Correct |
7 ms |
212 KB |
Output is correct |
21 |
Correct |
7 ms |
212 KB |
Output is correct |
22 |
Correct |
23 ms |
596 KB |
Output is correct |
23 |
Correct |
23 ms |
616 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
320 KB |
Output is correct |
4 |
Correct |
0 ms |
324 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
2 ms |
596 KB |
Output is correct |
11 |
Correct |
94 ms |
13380 KB |
Output is correct |
12 |
Correct |
93 ms |
13460 KB |
Output is correct |
13 |
Correct |
88 ms |
13572 KB |
Output is correct |
14 |
Correct |
87 ms |
13476 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
0 ms |
212 KB |
Output is correct |
22 |
Correct |
0 ms |
212 KB |
Output is correct |
23 |
Correct |
66 ms |
6956 KB |
Output is correct |
24 |
Correct |
51 ms |
4480 KB |
Output is correct |
25 |
Correct |
40 ms |
3684 KB |
Output is correct |
26 |
Correct |
48 ms |
2908 KB |
Output is correct |
27 |
Correct |
15 ms |
340 KB |
Output is correct |
28 |
Correct |
10 ms |
212 KB |
Output is correct |
29 |
Correct |
7 ms |
316 KB |
Output is correct |
30 |
Correct |
7 ms |
212 KB |
Output is correct |
31 |
Correct |
7 ms |
212 KB |
Output is correct |
32 |
Correct |
23 ms |
596 KB |
Output is correct |
33 |
Correct |
23 ms |
616 KB |
Output is correct |
34 |
Correct |
1 ms |
212 KB |
Output is correct |
35 |
Correct |
67 ms |
13592 KB |
Output is correct |
36 |
Correct |
125 ms |
13500 KB |
Output is correct |
37 |
Correct |
93 ms |
13652 KB |
Output is correct |
38 |
Correct |
1 ms |
328 KB |
Output is correct |
39 |
Correct |
1 ms |
316 KB |
Output is correct |
40 |
Correct |
0 ms |
212 KB |
Output is correct |
41 |
Correct |
1 ms |
212 KB |
Output is correct |
42 |
Correct |
0 ms |
212 KB |
Output is correct |
43 |
Correct |
0 ms |
212 KB |
Output is correct |
44 |
Correct |
1 ms |
212 KB |
Output is correct |
45 |
Correct |
23 ms |
728 KB |
Output is correct |
46 |
Incorrect |
5 ms |
972 KB |
Output isn't correct |
47 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
66 ms |
6956 KB |
Output is correct |
10 |
Correct |
51 ms |
4480 KB |
Output is correct |
11 |
Correct |
40 ms |
3684 KB |
Output is correct |
12 |
Correct |
48 ms |
2908 KB |
Output is correct |
13 |
Correct |
15 ms |
340 KB |
Output is correct |
14 |
Correct |
10 ms |
212 KB |
Output is correct |
15 |
Correct |
7 ms |
316 KB |
Output is correct |
16 |
Correct |
7 ms |
212 KB |
Output is correct |
17 |
Correct |
7 ms |
212 KB |
Output is correct |
18 |
Correct |
23 ms |
596 KB |
Output is correct |
19 |
Correct |
23 ms |
616 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
67 ms |
13592 KB |
Output is correct |
22 |
Correct |
125 ms |
13500 KB |
Output is correct |
23 |
Correct |
93 ms |
13652 KB |
Output is correct |
24 |
Execution timed out |
1049 ms |
2508 KB |
Time limit exceeded |
25 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
320 KB |
Output is correct |
4 |
Correct |
0 ms |
324 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
2 ms |
596 KB |
Output is correct |
11 |
Correct |
94 ms |
13380 KB |
Output is correct |
12 |
Correct |
93 ms |
13460 KB |
Output is correct |
13 |
Correct |
88 ms |
13572 KB |
Output is correct |
14 |
Correct |
87 ms |
13476 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
0 ms |
212 KB |
Output is correct |
22 |
Correct |
0 ms |
212 KB |
Output is correct |
23 |
Correct |
66 ms |
6956 KB |
Output is correct |
24 |
Correct |
51 ms |
4480 KB |
Output is correct |
25 |
Correct |
40 ms |
3684 KB |
Output is correct |
26 |
Correct |
48 ms |
2908 KB |
Output is correct |
27 |
Correct |
15 ms |
340 KB |
Output is correct |
28 |
Correct |
10 ms |
212 KB |
Output is correct |
29 |
Correct |
7 ms |
316 KB |
Output is correct |
30 |
Correct |
7 ms |
212 KB |
Output is correct |
31 |
Correct |
7 ms |
212 KB |
Output is correct |
32 |
Correct |
23 ms |
596 KB |
Output is correct |
33 |
Correct |
23 ms |
616 KB |
Output is correct |
34 |
Correct |
1 ms |
328 KB |
Output is correct |
35 |
Correct |
1 ms |
316 KB |
Output is correct |
36 |
Correct |
0 ms |
212 KB |
Output is correct |
37 |
Correct |
1 ms |
212 KB |
Output is correct |
38 |
Correct |
0 ms |
212 KB |
Output is correct |
39 |
Correct |
0 ms |
212 KB |
Output is correct |
40 |
Correct |
1 ms |
212 KB |
Output is correct |
41 |
Correct |
23 ms |
728 KB |
Output is correct |
42 |
Incorrect |
5 ms |
972 KB |
Output isn't correct |
43 |
Halted |
0 ms |
0 KB |
- |