-
Codeforces Round #462 (Div. 2) - A. A Compatible Pair코드포스(CodeForce) 2018. 8. 17. 18:30반응형
1. 문제
2. 알고리즘
키워드 - 구현
* 최노키오 소견
FACT - 음수 곱하기 음수는 양수가 된다.
3. 코드
1234567891011121314151617181920212223242526272829303132333435363738#include<map>#include<algorithm>#include<vector>#include<string>#include<iostream>using namespace std;long long INF = 1ull << 61;int main(){int n, m; cin >> n >> m;vector<long long> arr(n), brr(m);for (int i = 0; i < n; ++i) cin >> arr[i];for (int i = 0; i < m; ++i) cin >> brr[i];long long tmp = -INF;int selIdx = -1;for (int i = 0; i < arr.size(); ++i)for (int j = 0; j < brr.size(); ++j) {long long cand = arr[i] * brr[j];if (tmp < cand) {tmp = cand;selIdx = i;}}vector<long long> crr;for (int i = 0; i < arr.size(); ++i) if (i != selIdx) crr.push_back(arr[i]);long long tmp2 = -INF;for (int i = 0; i < crr.size(); ++i)for (int j = 0; j < brr.size(); ++j) {long long cand = crr[i] * brr[j];if (tmp2 < cand) tmp2 = cand;}cout << tmp2;return 0;}cs 반응형'코드포스(CodeForce)' 카테고리의 다른 글
Codeforces Round #613 (Div. 2) (0) 2020.01.16 Codeforces Round #512 (Div 2) - A. In Search of an Easy Problem (0) 2018.09.30 Educational Codeforces Round 38 (Rated for Div. 2) - Word Correction (0) 2018.08.17 Educational Codeforces Round 38 (Rated for Div. 2) - Run For Your Prize (0) 2018.08.17 Educational Codeforces Round 37 (Rated for Div. 2) - A. Water The Garden (0) 2018.08.17