/ SeriousOJ /

Record Detail

Compile Error

foo.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.

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
C99 (GCC 13.2.0)
Submit At
2024-10-05 03:03:54
Judged At
2024-11-11 02:40:55
Judged By
Score
0
Total Time
0ms
Peak Memory
0 Bytes