結果
問題 | No.2495 Three Sets |
ユーザー | kotatsugame |
提出日時 | 2023-10-06 22:46:16 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 464 ms / 3,000 ms |
コード長 | 993 bytes |
コンパイル時間 | 569 ms |
コンパイル使用メモリ | 64,428 KB |
実行使用メモリ | 4,380 KB |
最終ジャッジ日時 | 2023-10-06 22:46:26 |
合計ジャッジ時間 | 10,094 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 349 ms
4,376 KB |
testcase_01 | AC | 316 ms
4,376 KB |
testcase_02 | AC | 429 ms
4,376 KB |
testcase_03 | AC | 343 ms
4,380 KB |
testcase_04 | AC | 322 ms
4,376 KB |
testcase_05 | AC | 322 ms
4,380 KB |
testcase_06 | AC | 414 ms
4,376 KB |
testcase_07 | AC | 446 ms
4,380 KB |
testcase_08 | AC | 430 ms
4,380 KB |
testcase_09 | AC | 325 ms
4,380 KB |
testcase_10 | AC | 335 ms
4,380 KB |
testcase_11 | AC | 439 ms
4,380 KB |
testcase_12 | AC | 434 ms
4,380 KB |
testcase_13 | AC | 450 ms
4,380 KB |
testcase_14 | AC | 455 ms
4,380 KB |
testcase_15 | AC | 464 ms
4,376 KB |
testcase_16 | AC | 463 ms
4,380 KB |
testcase_17 | AC | 463 ms
4,376 KB |
testcase_18 | AC | 222 ms
4,380 KB |
testcase_19 | AC | 219 ms
4,380 KB |
testcase_20 | AC | 455 ms
4,376 KB |
ソースコード
#include<iostream> #include<cassert> using namespace std; const int off=3000; int A[2*off+1],Acnt[2*off+1],Asum[2*off+1]; int B[2*off+1],Bcnt[2*off+1],Bsum[2*off+1]; int C[2*off+1],Ccnt[2*off+1],Csum[2*off+1]; void rd(int N,int A[],int Acnt[],int Asum[]) { for(int i=0;i<N;i++) { int a;cin>>a; A[a+off]++; Acnt[a+off]++; Asum[a+off]+=a; } for(int i=2*off-1;i>=0;i--) { Acnt[i]+=Acnt[i+1]; Asum[i]+=Asum[i+1]; } } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int NA,NB,NC; cin>>NA>>NB>>NC; rd(NA,A,Acnt,Asum); rd(NB,B,Bcnt,Bsum); rd(NC,C,Ccnt,Csum); long long ans=0; for(int la=-off;la<=off;la++)for(int lb=-off;lb<=off;lb++) { long long now=(long long)Asum[la+off]*Bcnt[lb+off]; long long x=Acnt[la+off],y=Bsum[lb+off]; //C->C*Acnt[la+off]+Bsum[lb+off]>=0 //C->C*x+y>=0 //C>=-y/x int lc=x==0?y==0?off:-off:-y>=0?(-y+x-1)/x:-y/x; lc=max(min(lc,off),-off); now+=Csum[lc+off]*x+Ccnt[lc+off]*y; ans=max(ans,now); } cout<<ans<<endl; }