QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#879611#9123. Kth Sumucup-team4153RE 2770ms4864kbC++141.9kb2025-02-02 07:56:312025-02-02 07:56:32

Judging History

This is the latest submission verdict.

  • [2025-02-02 07:56:32]
  • Judged
  • Verdict: RE
  • Time: 2770ms
  • Memory: 4864kb
  • [2025-02-02 07:56:31]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;using ll=long long;using pii=pair<int,int>;
const int M=998244353,P=5e4,N=P+5,K=1e3,lim=1e6,G=P;const ll inf=1e17;
struct S
{
	int n,K;vector<vector<ll>>a,pre;
    bool trial(ll val)//first >=k_count:val<=
    {
        ll res=0;
        for(int i=0;i<3;i++)
        {
            auto&va=a[i];auto&vp=pre[i];
            for(int pa=(i==0?1:K+1),pp=K*K;pa<=n;pa++)
            {
                while(pp&&va[pa]+vp[pp]>val)pp--;
                res+=pp;//cout<<pa<<"%"<<pp<<'\n';
            }
        }
        for(int z=0;z<3;z++,swap(a[0],a[1]),swap(a[1],a[2]))//i<=K,j&k>K
        {
            for(int i=1;i<=1000;i++)
            {
                int lim=min(int(1e9)/(K+1)/i,P);ll vl=val-a[0][i];
                for(int j=K+1,k=lim;j<=lim&&k>K;)
                {
                    if(a[1][j]+a[2][k]<=vl)j++,res+=k-K;
                    else k--;
                }
            }
        }
        //cout<<val<<"%"<<res<<'\n';
        return res>=K;
    }
    void solve()
	{
        /*j,k>1000,i precal
        {
            int sum=0;for(int i=1;i<=1000;i++)sum+=max(min(lim/i,G)-1000,0);
            cout<<sum<<'\n';
            //3887282+1e6 presort
        }*/
        cin>>n>>K;a.resize(3,vector<ll>(N+1,inf));pre.resize(3,vector<ll>(1,0));
        for(int i=0;i<3;i++){for(int j=1;j<=n;j++)cin>>a[i][j];sort(a[i].begin()+1,a[i].begin()+n+1);}
        for(int i=0;i<3;i++)
        {
            auto&v0=pre[i];auto&v1=a[(i+1)%3];auto&v2=a[(i+2)%3];
            for(int j=1;j<=K;j++)for(int k=1;k<=K;k++)v0.push_back(v1[j]+v2[k]);
            sort(v0.begin()+1,v0.end());
        }
        ll L=0,R=3.1e9;//3.1e9
        while(R-L>1){ll mid=L+R>>1;trial(mid)?R=mid:L=mid;}cout<<R<<'\n';
    }
};
void precal(){}
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);precal();
	int t=1;//cin>>t;
	while(t--){S SS;SS.solve();}
}

详细

Test #1:

score: 100
Accepted
time: 2770ms
memory: 4736kb

input:

2 4
1 2
3 4
5 6

output:

10

result:

ok "10"

Test #2:

score: 0
Accepted
time: 2320ms
memory: 4864kb

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: 2770ms
memory: 4864kb

input:

1 1
1000000000
1000000000
1000000000

output:

3000000000

result:

ok "3000000000"

Test #4:

score: -100
Runtime Error

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:


result: