QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#447317 | #5754. Minimum Scalar Product | Sunnyzbh | 15 ✓ | 2ms | 3660kb | C++14 | 556b | 2024-06-18 09:37:07 | 2024-06-18 09:37:07 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int N=1005;
int n;
int tt,tc;
ll a[N],b[N];
void solve(){
cin>>n;
for(int i=1;i<=n;i++) cin>>a[i];
for(int i=1;i<=n;i++) cin>>b[i];
sort(a+1,a+n+1);
sort(b+1,b+n+1);
reverse(b+1,b+n+1);
ll ans=0;
for(int i=1;i<=n;i++){
ans+=a[i]*b[i];
}
cout<<"Case #"<<tt<<": ";
cout<<ans<<'\n';
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cin>>tc;
for(tt=1;tt<=tc;tt++) solve();
return 0;
}
詳細信息
Subtask #1:
score: 5
Accepted
Test #1:
score: 5
Accepted
time: 0ms
memory: 3568kb
input:
1000 3 -5 3 1 1 4 -2 5 3 1 5 2 4 0 1 1 0 1 8 372 887 -30 -600 -63 -947 526 307 -430 -426 -168 -538 350 515 988 299 7 891 -7 -475 163 495 -52 305 -381 248 -2 458 -114 -44 -47 1 -399 -394 8 49 31 -847 -310 348 -746 244 -907 11 -952 -772 741 -655 770 283 393 4 850 251 209 -896 237 669 884 -733 3 604 -8...
output:
Case #1: -25 Case #2: 6 Case #3: -2189090 Case #4: -647840 Case #5: 157206 Case #6: -2258343 Case #7: -1215806 Case #8: -678102 Case #9: -2052381 Case #10: -3313 Case #11: -1012446 Case #12: -2501563 Case #13: -2486781 Case #14: -2337367 Case #15: -331927 Case #16: -3202403 Case #17: -2351174 Case #...
result:
ok 1000 lines
Subtask #2:
score: 10
Accepted
Test #2:
score: 10
Accepted
time: 2ms
memory: 3660kb
input:
10 800 -99991 99994 99990 -99996 -99997 -99995 -99992 99996 -99994 -99998 99995 -99995 99998 99990 99995 -99994 -100000 -99993 -99992 -99994 99993 99997 -99998 99998 99995 99999 99999 -99994 -99994 99996 99996 -99995 -99990 99996 100000 -99997 99991 99998 99991 99995 -99995 -99991 99992 -100000 -999...
output:
Case #1: -7679252425391 Case #2: 7999194112308 Case #3: -2403218837859 Case #4: -1667618153839 Case #5: -3549092346279 Case #6: -1565711442951 Case #7: -3107964725218 Case #8: -3683981926681 Case #9: -485263372448 Case #10: -2737947356587
result:
ok 10 lines
Extra Test:
score: 0
Extra Test Passed