# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
803642 |
2023-08-03T05:13:34 Z |
vjudge1 |
Self Study (JOI22_ho_t2) |
C++14 |
|
1000 ms |
21424 KB |
#include<bits/stdc++.h>
#define fi first
#define se second
#define ll long long
using namespace std ;
const ll N = 3e5 ;
ll n, m, l = 0, r = 1e18, a[N + 1], b[N + 1] ;
set<pair<ll, ll>> s, s1, s2 ;
signed main()
{
ios_base::sync_with_stdio( 0 ) ;
cin.tie( 0 ) ;
cout.tie( 0 ) ;
cin >> n >> m ;
for(ll i = 1 ; i <= n ; i++)
cin >> a[i] ;
for(ll i = 1 ; i <= n ; i++)
{
cin >> b[i] ;
if(b[i] >= a[i])
s.insert({m, i}) ;
else
s2.insert({m, i}) ;
}
while(l + 1 < r)
{
s1 = s ;
ll mid = (l + r) >> 1, cnt = 0 ;
for(int i = 1 ; i <= n ; i++)
{
if(a[i] > b[i])
{
}
else
{
ll num = (mid + b[i] - 1) / b[i] ;
while(s1.size() && num)
{
pair<ll, ll> p = (*s1.rbegin()) ;
s1.erase(p) ;
ll abu = min(num, p.fi) ;
num -= abu ;
p.fi -= abu ;
if(p.fi)
s1.insert({p.fi, p.se}) ;
}
// cout << i << ' ' << mid << ' ' << num << '\n' ;
if(num)
{
cnt = 1e18 ;
break ;
}
}
}
if(cnt > m)
r = mid ;
else
l = mid ;
}
cout << l ;
return 0 ;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
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 |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 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 |
0 ms |
212 KB |
Output is correct |
9 |
Execution timed out |
1094 ms |
21424 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
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 |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 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 |
0 ms |
212 KB |
Output is correct |
9 |
Execution timed out |
1094 ms |
21424 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |