Submission #702640

# Submission time Handle Problem Language Result Execution time Memory
702640 2023-02-24T16:34:40 Z Chal1shkan Self Study (JOI22_ho_t2) C++14
0 / 100
303 ms 10752 KB
# include <bits/stdc++.h>
 
# define pb push_back
# define ff first
# define ss second
# define nl "\n"
# define sz(x) ((int)(x).size())
# define deb(x) cerr << #x  << " = " << x << endl; 
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
const ll maxn = 3e5 + 25;
const ll inf = 2e9 + 0;
const ll mod = 998244353;
const ll dx[] = {-1, 1, 0, 0};
const ll dy[] = {0, 0, -1, 1};
 
using namespace std;

ll n, m;
pair <ll, ll> p[maxn];	

bool ok (ll x)
{
	ll cur = 0;
	for (ll i = 1; i <= n; ++i)
	{
		p[i].ff = max(p[i].ff, p[i].ss);
		if (m * p[i].ff >= x)
		{
			cur += (x + p[i].ff - 1) / p[i].ff;
		}
		else
		{
			cur += m + (x - p[i].ff * m + p[i].ss - 1) / p[i].ss;
		}
	}
	return (cur <= n * m);
}

void ma1n (/* SABR */)
{
	cin >> n >> m;
	for (ll i = 1; i <= n; ++i)
	{
		cin >> p[i].ff;
	}
	for (ll i = 1; i <= n; ++i)
	{
		cin >> p[i].ss;
	}
	ll l = 0, r = 1e18, ans = 0;
	while (l <= r)
	{
		ll mid = (l + r) >> 1;
		if (ok(mid))
		{
			l = mid + 1;
			ans = mid;
		}
		else
		{
			r = mid - 1;
		}
	}
	cout << ans;
}
 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
//    freopen("angry.in", "r", stdin);
//    freopen("angry.out", "w", stdout);
    int ttt = 1;
//  cin >> ttt;
    for (int test = 1; test <= ttt; ++test)
    {
//      cout << "Case " << test << ":" << ' ';
        ma1n();
    }
    return 0;
}
# 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 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 Correct 1 ms 212 KB Output is correct
10 Correct 3 ms 340 KB Output is correct
11 Correct 166 ms 8576 KB Output is correct
12 Correct 163 ms 10752 KB Output is correct
13 Correct 154 ms 8696 KB Output is correct
14 Incorrect 303 ms 8748 KB Output isn't correct
15 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 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 Correct 78 ms 2660 KB Output is correct
10 Correct 53 ms 1876 KB Output is correct
11 Correct 45 ms 1492 KB Output is correct
12 Correct 32 ms 1236 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Incorrect 5 ms 340 KB Output isn't correct
19 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 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 Correct 1 ms 212 KB Output is correct
10 Correct 3 ms 340 KB Output is correct
11 Correct 166 ms 8576 KB Output is correct
12 Correct 163 ms 10752 KB Output is correct
13 Correct 154 ms 8696 KB Output is correct
14 Incorrect 303 ms 8748 KB Output isn't correct
15 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 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 Correct 78 ms 2660 KB Output is correct
10 Correct 53 ms 1876 KB Output is correct
11 Correct 45 ms 1492 KB Output is correct
12 Correct 32 ms 1236 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Incorrect 5 ms 340 KB Output isn't correct
19 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 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 Correct 1 ms 212 KB Output is correct
10 Correct 3 ms 340 KB Output is correct
11 Correct 166 ms 8576 KB Output is correct
12 Correct 163 ms 10752 KB Output is correct
13 Correct 154 ms 8696 KB Output is correct
14 Incorrect 303 ms 8748 KB Output isn't correct
15 Halted 0 ms 0 KB -