QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#873387 | #9123. Kth Sum | IvanZhang2009 | WA | 115ms | 5868kb | C++14 | 3.8kb | 2025-01-26 12:53:05 | 2025-01-26 12:53:05 |
Judging History
answer
/*
* __----~~~~~~~~~~~------___
* . . ~~//====...... __--~ ~~
* -. \_|// |||\\ ~~~~~~::::... /~
* ___-==_ _-~o~ \/ ||| \\ _/~~-
* __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~
* _-~~ .=~ | \\-_ '-~7 /- / || \ /
* .~ .~ | \\ -_ / /- / || \ /
* / ____ / | \\ ~-_/ /|- _/ .|| \ /
* |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\
* ' ~-| /| |-~\~~ __--~~
* |-~~-_/ | | ~\_ _-~ /\
* / \ \__ \/~ \__
* _--~ _/ | .-~~____--~-/ ~~==.
* ((->/~ '.|||' -_| ~~-/ , . _||
* -_ ~\ ~~---l__i__i__i--~~_/
* _-~-__ ~) \--______________--~~
* //.-~~~-~_--~- |-------~~~~~~~~
* //.-~~~--\
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
* 神兽保佑 永无BUG
*/
/*
* @Description: I want to be the weakest vegetable in the world!
* @Author: I.Z.
*/
#include<bits/stdc++.h>
using namespace std;
#define MOD 998244353
#define speMOD 2933256077ll
#define int long long
#define pii pair<int,int>
#define all(v) v.begin(),v.end()
#define pb push_back
#define REP(i,b,e) for(int i=(b);i<(int)(e);++i)
#define over(x) {cout<<(x)<<endl;return;}
#define lowbit(x) ((x)&(-(x)))
#define cntbit(x) __builtin_popcount(x)
#define deal(v) sort(all(v));v.erase(unique(v.begin(),v.end()),v.end())
#define lbound(v,x) lower_bound(all(v),x)-v.begin()
mt19937 sd(random_device{}());
int qpow(int a,int b,int m=MOD,int res=1){
a%=m;
while(b>0)res=(b&1)?(res*a%m):(res),a=a*a%m,b>>=1;
return res;
}
int exgcd(int x,int y,int &a,int &b){
if(y==0){
a=1;b=0;
return x;
}
int d=exgcd(y,x%y,a,b);
int z=b;
b=a-b*(x/y);
a=z;
return d;
}
int _x_,_y_;
inline int inverse(int x,int y=MOD){
exgcd(x,y,_x_,_y_);
return (_x_+y)%y;
}
int fac[2000005],inv[2000005];
void init(int n){
fac[0]=inv[0]=1;
REP(i,1,n+1)fac[i]=fac[i-1]*i%MOD;
inv[n]=qpow(fac[n],MOD-2);
for(int i=n-1;i>=1;--i)inv[i]=inv[i+1]*(i+1)%MOD;
}
int binom(int x,int y){
return x<y||y<0? 0:fac[x]*inv[y]%MOD*inv[x-y]%MOD;
}
int n,k;
int a[100005],b[100005],c[100005];
int B;
bool check(int x){
REP(i,0,B){
REP(j,0,B){
int t=k/(i+1)/(j+1);
while(t*(i+1)*(j+1)<=k)++t;
if(t<=n){
if(a[i]+b[j]+c[t]<=x)return 0;
if(a[i]+b[t]+c[j]<=x)return 0;
if(a[t]+b[i]+c[j]<=x)return 0;
}
}
}
int r=0;
REP(i,0,B){
REP(j,0,B){
int t=upper_bound(c,c+n,x-a[i]-b[j])-c;
r+=t;
t=upper_bound(b,b+n,x-a[i]-c[j])-b;
r+=max(0ll,t-B);
t=upper_bound(a,a+n,x-b[i]-c[j])-a;
r+=max(0ll,t-B);
}
}
return r<=k;
}
void Main() {
cin>>n>>k;
REP(i,0,n)cin>>a[i];
REP(i,0,n)cin>>b[i];
REP(i,0,n)cin>>c[i];
sort(a,a+n);sort(b,b+n);sort(c,c+n);
a[n]=b[n]=c[n]=4e9;
B=cbrt(k)+1;
int l=0,r=3e9,res=0;//最后一个 <=x 的最多有 k-1 个的
--k;
while(l<=r){
int mid=(l+r)>>1;
if(check(mid))res=mid,l=mid+1;
else r=mid-1;
}
over(res+1)
}
void TC() {
int tc=1;
while(tc--){
Main();
cout.flush();
}
cerr<<clock()<<endl;
}
signed main() {
return cin.tie(0),cout.tie(0),ios::sync_with_stdio(0),TC(),0;
}
/*
1. CLEAR the arrays (ESPECIALLY multitests)
2. DELETE useless output
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 5760kb
input:
2 4 1 2 3 4 5 6
output:
10
result:
ok "10"
Test #2:
score: 0
Accepted
time: 0ms
memory: 5864kb
input:
10 40 11 9 13 12 15 11 11 2 11 17 3 1 10 2 12 18 9 11 11 15 14 9 4 14 16 9 20 2 1 18
output:
14
result:
ok "14"
Test #3:
score: 0
Accepted
time: 1ms
memory: 5868kb
input:
1 1 1000000000 1000000000 1000000000
output:
3000000000
result:
ok "3000000000"
Test #4:
score: 0
Accepted
time: 115ms
memory: 5864kb
input:
314 12491830 429392519 92131736 9460149 448874040 5326166 804308891 571581523 580832602 110825817 11150177 47845585 886171410 888601860 633656718 879205016 333690452 739013504 118317331 8289119 502971381 486014573 167383690 96016893 556946780 634198668 389358242 984894049 735281439 58642904 22106451...
output:
1346801336
result:
ok "1346801336"
Test #5:
score: -100
Wrong Answer
time: 1ms
memory: 5868kb
input:
34 34490 133495256 283197838 857697935 858259368 959152648 301897236 990604260 865643006 704101978 322295867 324109158 258113372 423370893 16000407 224364583 353708691 265955784 183826167 813127458 476308169 634865805 973017138 197716378 674895784 956141489 277068847 534893183 817797721 662940992 82...
output:
2150079917
result:
wrong answer 1st words differ - expected: '2149314674', found: '2150079917'