#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define SZ(x) ((int)((x).size()))
#define pow2(x) ((ll)(x) * (x))
const ll mod = 1e9 + 7;
const int INF = 1e9 + 5; // 998244353
const ll INFF = 1e18 + 5;
// Super is the cutest girl
void solve()
{
int n, m;
cin >> n >> m;
vector<pll> v(n);
for (int i = 0; i < n; i++)
{
cin >> v[i].fi;
}
for (int i = 0; i < n; i++)
{
cin >> v[i].se;
}
// ll ans = INF;
// for (int i = 0; i < n; i++)
// {
// ans = min(ans, max(v[i].fi, v[i].se));
// }
// cout << ans << '\n';
vl curr(n + 1, 0);
priority_queue<pll> pq;
for (int i = 0; i < n; i++)
{
pq.push({0, i});
}
for (int i = 0; i < n * m; i++)
{
pll u = pq.top();
u.fi = -u.fi;
curr[u.se] += v[u.se].fi;
pq.pop();
pq.push({-curr[u.se], u.se});
}
ll ans = INFF;
for (int i = 0; i < n; i++)
{
ans = min(ans, curr[i]);
}
cout << ans << '\n';
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
// int t; cin >> t; while(t--)
solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
456 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
452 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
53 ms |
10980 KB |
Output is correct |
10 |
Correct |
42 ms |
6868 KB |
Output is correct |
11 |
Correct |
30 ms |
5848 KB |
Output is correct |
12 |
Correct |
42 ms |
4084 KB |
Output is correct |
13 |
Correct |
13 ms |
348 KB |
Output is correct |
14 |
Correct |
7 ms |
348 KB |
Output is correct |
15 |
Correct |
5 ms |
348 KB |
Output is correct |
16 |
Correct |
4 ms |
460 KB |
Output is correct |
17 |
Correct |
4 ms |
348 KB |
Output is correct |
18 |
Correct |
19 ms |
604 KB |
Output is correct |
19 |
Correct |
19 ms |
860 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
52 ms |
17048 KB |
Output is correct |
22 |
Correct |
71 ms |
16280 KB |
Output is correct |
23 |
Correct |
95 ms |
16072 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
456 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
452 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
53 ms |
10980 KB |
Output is correct |
10 |
Correct |
42 ms |
6868 KB |
Output is correct |
11 |
Correct |
30 ms |
5848 KB |
Output is correct |
12 |
Correct |
42 ms |
4084 KB |
Output is correct |
13 |
Correct |
13 ms |
348 KB |
Output is correct |
14 |
Correct |
7 ms |
348 KB |
Output is correct |
15 |
Correct |
5 ms |
348 KB |
Output is correct |
16 |
Correct |
4 ms |
460 KB |
Output is correct |
17 |
Correct |
4 ms |
348 KB |
Output is correct |
18 |
Correct |
19 ms |
604 KB |
Output is correct |
19 |
Correct |
19 ms |
860 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
52 ms |
17048 KB |
Output is correct |
22 |
Correct |
71 ms |
16280 KB |
Output is correct |
23 |
Correct |
95 ms |
16072 KB |
Output is correct |
24 |
Execution timed out |
1008 ms |
3548 KB |
Time limit exceeded |
25 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |