/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 320.0 KiB
#2 Wrong Answer 2ms 560.0 KiB
#3 Wrong Answer 18ms 324.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    
    int T;
    cin >> T;
    
    while(T--){
        long long N, M;
        cin >> N >> M;
        long long total = N * M;
        vector<long long> A(total);
        for(auto &x : A) cin >> x;
        
        sort(A.begin(), A.end());
        
        // Determine sizes of Set A and Set B
        long long A_size = (total + 1) / 2; // ceil(N*M /2)
        long long B_size = total / 2;       // floor(N*M /2)
        
        // Smallest in Set A is the first element of the last A_size elements
        long long min_A = A[total - A_size];
        
        // Smallest in Set B is the first element
        long long min_B = A[0];
        
        long long minimal_sum = min_A + min_B;
        
        cout << minimal_sum << "\n";
    }
}

Information

Submit By
Type
Submission
Problem
P1065 Matrix Sum
Language
C++17 (G++ 13.2.0)
Submit At
2024-10-05 03:03:57
Judged At
2024-11-11 02:40:54
Judged By
Score
5
Total Time
18ms
Peak Memory
560.0 KiB