Submission #920333

# Submission time Handle Problem Language Result Execution time Memory
920333 2024-02-02T13:07:52 Z KiaRez Self Study (JOI22_ho_t2) C++17
0 / 100
436 ms 11088 KB
/*
    IN THE NAME OF GOD
*/
#include <bits/stdc++.h>

// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef long double ld;

#define F                                      first
#define S                                      second
#define Mp                                     make_pair
#define pb                                     push_back
#define pf                                     push_front
#define size(x)                                ((ll)x.size())
#define all(x)                                 (x).begin(),(x).end()
#define kill(x)		                           cout << x << '\n', exit(0);
#define fuck(x)                                cout << "(" << #x << " , " << x << ")" << endl
#define endl                                   '\n'

const int N = 3e5+23, lg = 18;
ll Mod = 1e9+7; //998244353;

inline ll MOD(ll a, ll mod=Mod) {a%=mod; (a<0)&&(a+=mod); return a;}
inline ll poww(ll a, ll b, ll mod=Mod) {
    ll ans = 1;
    a=MOD(a, mod);
    while (b) {
        if (b & 1) ans = MOD(ans*a, mod);
        b >>= 1;
        a = MOD(a*a, mod);
    }
    return ans;
}

ll n, m, a[N], b[N];
int main () {
	ios_base::sync_with_stdio(false), cin.tie(0);

	cin>>n>>m;
	for(int i=1; i<=n; i++) cin>>a[i];
	for(int i=1; i<=n; i++) cin>>b[i];
	ll l=0, r=1e18;
	while(r-l > 1) {
		ll mid = (l+r)/2;
		ll num = 0, yey = 1;
		for(int i=1; i<=n; i++) {
			if(a[i] >= b[i]) {
				ll x = (mid+a[i]-1)/a[i];
				x = min(x, m);
				num -= (m-x);
				ll f = mid - x*a[i];
				num += max(0ll, (f-1+b[i])/b[i]);
			} else {
				ll x = (mid+a[i]-1)/b[i];
				x = min(x, m);
				num -= (m-x);
				ll f = mid - x*b[i];
				num += max(0ll, (f-1+b[i])/b[i]);
			}
		}
		if(num <= 0) l=mid;
		else r=mid;
	}

	cout<<l<<endl;

	return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:53:15: warning: unused variable 'yey' [-Wunused-variable]
   53 |   ll num = 0, yey = 1;
      |               ^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 4 ms 2396 KB Output is correct
11 Correct 243 ms 10948 KB Output is correct
12 Correct 245 ms 11088 KB Output is correct
13 Correct 234 ms 8784 KB Output is correct
14 Incorrect 436 ms 9040 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 123 ms 7504 KB Output is correct
10 Correct 81 ms 6492 KB Output is correct
11 Correct 62 ms 6224 KB Output is correct
12 Correct 49 ms 5720 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Incorrect 9 ms 2392 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 4 ms 2396 KB Output is correct
11 Correct 243 ms 10948 KB Output is correct
12 Correct 245 ms 11088 KB Output is correct
13 Correct 234 ms 8784 KB Output is correct
14 Incorrect 436 ms 9040 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 123 ms 7504 KB Output is correct
10 Correct 81 ms 6492 KB Output is correct
11 Correct 62 ms 6224 KB Output is correct
12 Correct 49 ms 5720 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Incorrect 9 ms 2392 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 4 ms 2396 KB Output is correct
11 Correct 243 ms 10948 KB Output is correct
12 Correct 245 ms 11088 KB Output is correct
13 Correct 234 ms 8784 KB Output is correct
14 Incorrect 436 ms 9040 KB Output isn't correct
15 Halted 0 ms 0 KB -