답안 #1018905

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1018905 2024-07-10T10:45:43 Z vjudge1 Self Study (JOI22_ho_t2) C++17
100 / 100
216 ms 16628 KB
#include <bits/stdc++.h>
//~ #include <ext/pb_ds/assoc_container.hpp>
//~ #include <ext/pb_ds/tree_policy.hpp>
using namespace std; //using namespace __gnu_pbds; using namespace chrono;
#define ff first
#define ss second
#define pb push_back
#define gan(x) x.begin(),x.end()
#define rgan(x) x.rbegin(),x.rend()
#define ins insert
typedef long long ll;typedef vector<ll> vecs;typedef vector<vector<ll>> matrix;
#define forn(i, n) for (ll i = 0; i < ll(n); i++)
#define forn1(i, n) for (ll i = 1; i <= ll(n); i++)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update
const int mod = 1e9+7; const char nl = '\n';
const ll N = 1e5+5;
const ll inf = 1e18;

bool check ( ll mid , ll n , ll m , vecs v1 , vecs v2) {
	ll timee = 0 ;
	forn ( i , n ) {
		if ( v2 [ i ] > v1 [ i ] ) {
			ll b = ( mid + v2 [ i ] - 1 ) / v2 [ i ] ;
			timee += b;
		}
		else { if ( v1 [ i ] * 1ll * m >= mid ) {
			ll a = ( mid + v1 [ i ] - 1 ) / v1 [ i ] ;
			timee += a ;
		}
		else {
			ll a = m;
			ll b = ( mid - v1 [ i ] * 1ll * a + v2 [ i ] - 1 ) / v2 [ i ] ;
			timee += a + b;
		}
	}
		if ( timee > n * 1ll * m ) return false;
	}
	if ( timee <= n * 1ll * m ) return true;
	return false;
}

void ShikiMoril() {
 ll n, m; cin >> n >> m ;
  vecs v1 ( n ) , v2 ( n ) ;
  forn ( i , n )  cin >> v1 [ i ] ;
  forn ( i ,  n ) cin >> v2 [ i ] ;
  
  ll l = 1 , r = inf ;
  while ( r - l > 1 ) {
	  ll mid  = ( l + r ) >> 1 ;
	  if ( check ( mid  , n , m , v1 , v2  ) ) l = mid;
	  else r = mid;
  }
  if ( check ( r, n , m , v1 , v2 ) ) cout << r ;
  else cout << l ; 
}
signed main() {
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    // void freopen (){ freopen(".in", "r", stdin);freopen(".out", "w", stdout);}
    ll t = 1;  //cin >> t;
    while (t--) {
        ShikiMoril();
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 2 ms 604 KB Output is correct
11 Correct 180 ms 15788 KB Output is correct
12 Correct 191 ms 15756 KB Output is correct
13 Correct 145 ms 13756 KB Output is correct
14 Correct 131 ms 13864 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 113 ms 11388 KB Output is correct
17 Correct 164 ms 16456 KB Output is correct
18 Correct 165 ms 15796 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 113 ms 11388 KB Output is correct
3 Correct 164 ms 16456 KB Output is correct
4 Correct 165 ms 15796 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 456 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 452 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 76 ms 8160 KB Output is correct
14 Correct 57 ms 5648 KB Output is correct
15 Correct 40 ms 4264 KB Output is correct
16 Correct 32 ms 3500 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 372 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 604 KB Output is correct
23 Correct 2 ms 464 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 2 ms 604 KB Output is correct
11 Correct 180 ms 15788 KB Output is correct
12 Correct 191 ms 15756 KB Output is correct
13 Correct 145 ms 13756 KB Output is correct
14 Correct 131 ms 13864 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 456 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 452 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 76 ms 8160 KB Output is correct
24 Correct 57 ms 5648 KB Output is correct
25 Correct 40 ms 4264 KB Output is correct
26 Correct 32 ms 3500 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 372 KB Output is correct
29 Correct 0 ms 344 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 1 ms 604 KB Output is correct
33 Correct 2 ms 464 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 113 ms 11388 KB Output is correct
36 Correct 164 ms 16456 KB Output is correct
37 Correct 165 ms 15796 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 456 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 1 ms 452 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 2 ms 636 KB Output is correct
46 Correct 4 ms 908 KB Output is correct
47 Correct 1 ms 348 KB Output is correct
48 Correct 30 ms 3256 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
51 Correct 2 ms 600 KB Output is correct
52 Correct 0 ms 348 KB Output is correct
53 Correct 0 ms 348 KB Output is correct
54 Correct 0 ms 456 KB Output is correct
55 Correct 91 ms 8108 KB Output is correct
56 Correct 52 ms 4852 KB Output is correct
57 Correct 48 ms 5064 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 456 KB Output is correct
3 Correct 0 ms 348 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 348 KB Output is correct
7 Correct 0 ms 452 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 76 ms 8160 KB Output is correct
10 Correct 57 ms 5648 KB Output is correct
11 Correct 40 ms 4264 KB Output is correct
12 Correct 32 ms 3500 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 372 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 604 KB Output is correct
19 Correct 2 ms 464 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 113 ms 11388 KB Output is correct
22 Correct 164 ms 16456 KB Output is correct
23 Correct 165 ms 15796 KB Output is correct
24 Correct 27 ms 2816 KB Output is correct
25 Correct 78 ms 7336 KB Output is correct
26 Correct 15 ms 2060 KB Output is correct
27 Correct 156 ms 15752 KB Output is correct
28 Correct 158 ms 15868 KB Output is correct
29 Correct 161 ms 15764 KB Output is correct
30 Correct 167 ms 15728 KB Output is correct
31 Correct 172 ms 15792 KB Output is correct
32 Correct 140 ms 11272 KB Output is correct
33 Correct 182 ms 16628 KB Output is correct
34 Correct 129 ms 11216 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 2 ms 604 KB Output is correct
11 Correct 180 ms 15788 KB Output is correct
12 Correct 191 ms 15756 KB Output is correct
13 Correct 145 ms 13756 KB Output is correct
14 Correct 131 ms 13864 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 456 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 452 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 76 ms 8160 KB Output is correct
24 Correct 57 ms 5648 KB Output is correct
25 Correct 40 ms 4264 KB Output is correct
26 Correct 32 ms 3500 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 372 KB Output is correct
29 Correct 0 ms 344 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 1 ms 604 KB Output is correct
33 Correct 2 ms 464 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 456 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 1 ms 452 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 2 ms 636 KB Output is correct
42 Correct 4 ms 908 KB Output is correct
43 Correct 1 ms 348 KB Output is correct
44 Correct 30 ms 3256 KB Output is correct
45 Correct 0 ms 348 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Correct 2 ms 600 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 0 ms 456 KB Output is correct
51 Correct 91 ms 8108 KB Output is correct
52 Correct 52 ms 4852 KB Output is correct
53 Correct 48 ms 5064 KB Output is correct
54 Correct 27 ms 2816 KB Output is correct
55 Correct 78 ms 7336 KB Output is correct
56 Correct 15 ms 2060 KB Output is correct
57 Correct 156 ms 15752 KB Output is correct
58 Correct 158 ms 15868 KB Output is correct
59 Correct 161 ms 15764 KB Output is correct
60 Correct 167 ms 15728 KB Output is correct
61 Correct 172 ms 15792 KB Output is correct
62 Correct 140 ms 11272 KB Output is correct
63 Correct 182 ms 16628 KB Output is correct
64 Correct 129 ms 11216 KB Output is correct
65 Correct 1 ms 348 KB Output is correct
66 Correct 113 ms 11388 KB Output is correct
67 Correct 164 ms 16456 KB Output is correct
68 Correct 165 ms 15796 KB Output is correct
69 Correct 20 ms 2108 KB Output is correct
70 Correct 4 ms 604 KB Output is correct
71 Correct 0 ms 348 KB Output is correct
72 Correct 42 ms 2652 KB Output is correct
73 Correct 5 ms 956 KB Output is correct
74 Correct 1 ms 468 KB Output is correct
75 Correct 178 ms 15792 KB Output is correct
76 Correct 184 ms 15780 KB Output is correct
77 Correct 194 ms 15864 KB Output is correct
78 Correct 196 ms 15828 KB Output is correct
79 Correct 215 ms 15684 KB Output is correct
80 Correct 216 ms 15808 KB Output is correct
81 Correct 168 ms 13772 KB Output is correct
82 Correct 158 ms 13844 KB Output is correct