QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#773532#5754. Minimum Scalar ProductKavenSky5 2ms3900kbC++23923b2024-11-23 09:16:452024-11-23 09:16:45

Judging History

你现在查看的是最新测评结果

  • [2024-11-23 09:16:45]
  • 评测
  • 测评结果:5
  • 用时:2ms
  • 内存:3900kb
  • [2024-11-23 09:16:45]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define MAX 300015
#define INF 1e8
#define none -1145141919810
const int N=3e5+5;
typedef pair<int,int> P;
typedef long long ll;
typedef __int128 i128;
const ll mod= 998244353;
typedef unsigned long long ull;
typedef long double db;
typedef pair<ll,ll>Pll;
const db pi=acosl(-1.0);
mt19937_64 rnd(time(0));
int cnt=0;
void solve(){
    cnt++;
    int n;
    cin >> n;
    vector<int>a(n),b(n);
    for(int i=0;i<n;i++) cin >> a[i];
    for(int i=0;i<n;i++) cin >> b[i];
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    reverse(a.begin(),a.end());
    ll ans=0;
    for(int i=0;i<n;i++) ans+=a[i]*b[i];
    cout << "Case #" << cnt << ": " << ans << "\n";
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    cout << fixed << setprecision(15);
    cin >> t;
    while(t--)
    solve();
}

详细

Subtask #1:

score: 5
Accepted

Test #1:

score: 5
Accepted
time: 2ms
memory: 3700kb

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: 0
Wrong Answer

Test #2:

score: 0
Wrong Answer
time: 2ms
memory: 3900kb

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: -1082182658735
Case #2: 1127246438708
Case #3: -28101923171
Case #4: -99955090799
Case #5: -61578901927
Case #6: -45293020167
Case #7: -58537945058
Case #8: -37554692377
Case #9: -72946512032
Case #10: -57887763883

result:

wrong answer 1st lines differ - expected: 'Case #1: -7679252425391', found: 'Case #1: -1082182658735'