Precreation contest files
This commit is contained in:
28
misc/hsg-hp-2025/cbai3.cpp
Normal file
28
misc/hsg-hp-2025/cbai3.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
int a[1000000];
|
||||
|
||||
int main() {
|
||||
ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
int m, n, S;
|
||||
cin >> m >> n >> S;
|
||||
for (int i = 0; i < m * n; i++)
|
||||
cin >> a[i];
|
||||
|
||||
sort(a, a + m * n);
|
||||
|
||||
int l = 0, r = m * n - 1;
|
||||
int cur_max = -1;
|
||||
while (l < r) {
|
||||
if (a[l] + a[r] > S)
|
||||
r--;
|
||||
else {
|
||||
cur_max = max(cur_max, a[l] + a[r]);
|
||||
l++;
|
||||
}
|
||||
}
|
||||
cout << cur_max << '\n';
|
||||
}
|
||||
Reference in New Issue
Block a user