QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#113722 | #2628. Self Study | pdstiago | 26.666667 | 76ms | 8304kb | C++14 | 1.3kb | 2023-06-19 08:11:36 | 2023-06-19 08:11:39 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define mxn (int) 3e5+5
#define mxm (int) 1e5+5
#define f first
#define s second
#define pb push_back
#define es " "
#define endl "\n"
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define fastio ios_base::sync_with_stdio(false), cin.tie(nullptr)
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, int> pip;
typedef unsigned long long ull;
ll n, k, a[mxn], b[mxn];
ll solve(ll x){
ll cont=0;
for(int i=1; i<=n; i++){
if(b[i]>=a[i]){
cont+=(b[i]+x-1)/b[i];
}else{
ll qnt = min(k, (a[i]+x-1)/a[i]);
cont+=qnt;
ll resta = x - a[i]*qnt;
if(resta>0) cont+=(b[i]+resta-1)/b[i];
}
}
return cont<=(n*k);
}
int main(){
fastio;
cin >> n >> k;
for(int i=1; i<=n; i++){
cin >> a[i];
}
for(int i=1; i<=n; i++){
cin >> b[i];
}
ll ini=0, fim=(int)2e18, meio, resp;
while(ini<=fim){
meio=(ini+fim)/2;
if(solve(meio)){
ini=meio+1;
resp=meio;
}else{
fim=meio-1;
}
}
cout << resp << endl;
return 0;
}
詳細信息
Subtask #1:
score: 10
Accepted
Test #1:
score: 10
Accepted
time: 2ms
memory: 5628kb
input:
1 1 548641561 724453206
output:
724453206
result:
ok single line: '724453206'
Test #2:
score: 0
Accepted
time: 1ms
memory: 5608kb
input:
2 1 80304386 1597 1258971 98815137
output:
80304386
result:
ok single line: '80304386'
Test #3:
score: 0
Accepted
time: 0ms
memory: 5492kb
input:
3 1 718661397 138698100 479852432 476459687 907845291 453667817
output:
479852432
result:
ok single line: '479852432'
Test #4:
score: 0
Accepted
time: 1ms
memory: 5428kb
input:
4 1 40507275 25309 13 361883 8128172 62257460 3 1027728
output:
13
result:
ok single line: '13'
Test #5:
score: 0
Accepted
time: 0ms
memory: 5656kb
input:
5 1 991877575 974223811 527727300 578005153 205111294 310841900 329838723 543248627 534715774 830419619
output:
543248627
result:
ok single line: '543248627'
Test #6:
score: 0
Accepted
time: 1ms
memory: 5668kb
input:
6 1 673477 2620072 362852511 86 69304 4342089 247938 152093194 1 1775681 59980917 409
output:
673477
result:
ok single line: '673477'
Test #7:
score: 0
Accepted
time: 1ms
memory: 5512kb
input:
7 1 178014106 857686017 847502205 846499927 769922152 825294743 94179401 107076300 387039548 308448172 416996505 919652417 358968960 881155943
output:
178014106
result:
ok single line: '178014106'
Test #8:
score: 0
Accepted
time: 1ms
memory: 5488kb
input:
8 1 38952827 24114401 19 2 29754 391071941 895126917 27 66338173 5206521 1428592 7035 23684037 278 311 14429699
output:
7035
result:
ok single line: '7035'
Test #9:
score: 0
Accepted
time: 1ms
memory: 5508kb
input:
67 1 610928627 863614572 535107894 102892262 781620356 439829100 777321721 608856766 686478481 752884266 585966742 85481271 904743197 42797812 27698813 425144291 38360264 117768094 645740865 903621093 57241636 507954073 682213933 707630124 334595719 716583236 534534992 50416286 344293088 613848792 2...
output:
95375906
result:
ok single line: '95375906'
Test #10:
score: 0
Accepted
time: 2ms
memory: 5700kb
input:
4481 1 530263320 551405488 720280735 756921262 57615896 890005460 245664758 943419373 832394839 370240673 420526498 695670828 910866430 705658035 543576358 811997503 723914542 278031919 407895048 896804222 935879701 773845225 12699717 570880703 852422012 176717545 740287923 997989010 451013204 21496...
output:
12073279
result:
ok single line: '12073279'
Test #11:
score: 0
Accepted
time: 73ms
memory: 8304kb
input:
299999 1 353932896 283957966 10468088 561126160 702975326 865946692 549886847 881809173 22487130 377759910 103679048 7383003 533620194 601101806 658483835 596524345 643103064 242207881 180146144 156685989 785620097 337780504 174463500 517216117 937644576 779893031 616819943 353759011 10199744 587374...
output:
4481987
result:
ok single line: '4481987'
Test #12:
score: 0
Accepted
time: 76ms
memory: 8068kb
input:
300000 1 244960338 81301400 314994847 781781085 269762243 884560570 719108129 537499271 171153472 86878356 612696563 982213163 436289004 473491259 565304038 547393429 796429448 777777257 11490151 799145244 622205824 156454272 252970682 917967775 361170206 487728888 959769335 81559521 242249146 80493...
output:
1263603
result:
ok single line: '1263603'
Test #13:
score: 0
Accepted
time: 52ms
memory: 8120kb
input:
300000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...
output:
1000000000
result:
ok single line: '1000000000'
Test #14:
score: 0
Accepted
time: 58ms
memory: 8144kb
input:
300000 1 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 10000...
output:
1000000000
result:
ok single line: '1000000000'
Subtask #2:
score: 0
Wrong Answer
Test #15:
score: 25
Accepted
time: 1ms
memory: 5488kb
input:
3 3 430074929 299686894 507918575 430074929 299686894 507918575
output:
1015837150
result:
ok single line: '1015837150'
Test #16:
score: 0
Accepted
time: 1ms
memory: 5496kb
input:
8 2 838643951 240217016 261207069 66687076 628994327 646228382 585174644 909710002 838643951 240217016 261207069 66687076 628994327 646228382 585174644 909710002
output:
466809532
result:
ok single line: '466809532'
Test #17:
score: 0
Accepted
time: 1ms
memory: 5664kb
input:
5 3 97283122 448906411 242495629 994021326 237073930 97283122 448906411 242495629 994021326 237073930
output:
583698732
result:
ok single line: '583698732'
Test #18:
score: -25
Wrong Answer
time: 1ms
memory: 5624kb
input:
8 9 605252877 430369638 951054166 725102459 957083940 702833150 560462831 778843323 605252877 430369638 951054166 725102459 957083940 702833150 560462831 778843323
output:
2147483647
result:
wrong answer 1st lines differ - expected: '5706324996', found: '2147483647'
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 0
Wrong Answer
Test #54:
score: 0
Wrong Answer
time: 11ms
memory: 5880kb
input:
46277 26082660 216820392 975920171 670198908 751879346 785464410 137803695 990316039 136082781 508319725 285053836 962754829 189537126 843451157 603648162 288458523 785309345 169328756 469187125 338962865 683500991 389745945 300198265 425154931 243946562 947186175 802786983 215106495 843125200 25944...
output:
2147483647
result:
wrong answer 1st lines differ - expected: '1649349400858800', found: '2147483647'
Subtask #5:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
0%
Subtask #6:
score: 16.6667
Accepted