Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- /// from HUNG MINE with love <3
- int n, a[1000001];
- void inline read (int &x) {
- int flag = 1;
- x = 0;
- char c = getchar ();//cout << c << "\n";
- while (c < '0' || c > '9') {
- if (c == '-') {
- flag = -1;
- }
- c = getchar ();
- }
- while (c >= '0' && c <= '9') {
- x = x * 10 + (c - '0');
- c = getchar ();
- }
- x *= flag;//cerr << x;
- }
- int main () {
- // if (fopen ("test.inp", "r")) {
- // freopen ("test.inp", "r", stdin);
- // }
- {
- freopen ("MINPRODUCT.inp", "r", stdin);
- freopen ("MINPRODUCT.out", "w", stdout);
- }
- ios_base :: sync_with_stdio (0);
- cin.tie (0);
- cout.tie (0);
- read (n);//cerr << n;
- for (int i = 1; i <= n; ++ i) {
- read (a[i]);
- }
- sort (a + 1, a + n + 1);
- if (a[1] < 0 && a[n] > 0) return cout << a[1] * a[n], 0;
- if (a[n] <= 0) return cout << a[n - 1] * a[n], 0;
- if (a[1] >= 0) return cout << a[1] * a[2], 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement