Submission #5212035


Source Code Expand

#include <bits/stdc++.h>

#define For(i, l, r) for (register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for (register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Rep(i, r) for (register int i = (0), i##end = (int)(r); i < i##end; ++i)
#define Set(a, v) memset(a, v, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define debug(x) cout << #x << ": " << (x) << endl

using namespace std;

template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, T b) { return b > a ? a = b, 1 : 0; }

inline int read() {
    int x(0), sgn(1); char ch(getchar());
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') sgn = -1;
    for (; isdigit(ch); ch = getchar()) x = (x * 10) + (ch ^ 48);
    return x * sgn;
}

void File() {
#ifdef zjp_shadow
    freopen ("E.in", "r", stdin);
    freopen ("E.out", "w", stdout);
#endif
}

const int N = 2e5 + 1e3;

int n;

pair<int, int> a[N];

multiset<int> R, B;

#define Max(S) *S.rbegin()
#define Min(S) *S.begin()

int main() {

	File();

	n = read();
	For (i, 1, n) {
		int x = read(), y = read(); if (x > y) swap(x, y);
		B.insert(x); R.insert(y); a[i] = make_pair(x, y);
	}
	long long ans = 1ll * (Max(R) - Min(R)) * (Max(B) - Min(B));

	sort(a + 1, a + n + 1);
	For (i, 1, n) {
		B.erase(B.find(a[i].first)); R.insert(a[i].first);
		R.erase(R.find(a[i].second)); B.insert(a[i].second);
		chkmin(ans, 1ll * (Max(R) - Min(R)) * (Max(B) - Min(B)));
	}
	printf ("%lld\n", ans);

	return 0;

}

Submission Info

Submission Time
Task E - Ball Coloring
User zjp_shadow
Language C++14 (GCC 5.4.1)
Score 700
Code Size 1605 Byte
Status AC
Exec Time 697 ms
Memory 20608 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 700 / 700
Status
AC × 3
AC × 35
Set Name Test Cases
Sample example0, example1, example2
All div20, div21, div22, div23, div24, example0, example1, example2, maxrand0, maxrand1, maxrand2, maxrand20, maxrand21, maxrand210, maxrand211, maxrand22, maxrand23, maxrand24, maxrand25, maxrand26, maxrand27, maxrand28, maxrand29, maxrand3, maxrand4, smallrand0, smallrand1, smallrand2, smallrand3, smallrand4, sparse0, sparse1, sparse2, sparse3, sparse4
Case Name Status Exec Time Memory
div20 AC 697 ms 20608 KB
div21 AC 681 ms 20608 KB
div22 AC 677 ms 20608 KB
div23 AC 681 ms 20608 KB
div24 AC 653 ms 20608 KB
example0 AC 1 ms 256 KB
example1 AC 1 ms 256 KB
example2 AC 1 ms 256 KB
maxrand0 AC 636 ms 20608 KB
maxrand1 AC 683 ms 20608 KB
maxrand2 AC 657 ms 20608 KB
maxrand20 AC 519 ms 20608 KB
maxrand21 AC 550 ms 20608 KB
maxrand210 AC 398 ms 20608 KB
maxrand211 AC 533 ms 20608 KB
maxrand22 AC 595 ms 20608 KB
maxrand23 AC 651 ms 20608 KB
maxrand24 AC 638 ms 20608 KB
maxrand25 AC 424 ms 20608 KB
maxrand26 AC 475 ms 20608 KB
maxrand27 AC 668 ms 20608 KB
maxrand28 AC 663 ms 20608 KB
maxrand29 AC 639 ms 20608 KB
maxrand3 AC 626 ms 20608 KB
maxrand4 AC 616 ms 20608 KB
smallrand0 AC 2 ms 256 KB
smallrand1 AC 1 ms 256 KB
smallrand2 AC 2 ms 256 KB
smallrand3 AC 1 ms 256 KB
smallrand4 AC 1 ms 256 KB
sparse0 AC 391 ms 20608 KB
sparse1 AC 399 ms 20608 KB
sparse2 AC 382 ms 20608 KB
sparse3 AC 406 ms 20608 KB
sparse4 AC 397 ms 20608 KB