Submission #1302293


Source Code Expand

#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <string>
#include <iostream>
#include <climits>
using namespace std;

#define int long long
const int INF = LLONG_MAX*0.8;
typedef pair<int, int> PII;

int N;
vector<PII> v;

signed main()
{
	int mi = INF, ma = -INF;
	int rMax = -INF, bMin = INF;
	cin >> N;
	v.resize(N);
	for (int i = 0; i < N; i++)
	{
		cin >> v[i].first >> v[i].second;
		if (v[i].first > v[i].second) swap(v[i].first, v[i].second);
		mi = min(mi, v[i].first);
		ma = max(ma, v[i].second);
		rMax = max(rMax, v[i].first);
		bMin = min(bMin, v[i].second);
	}
	int ans = (rMax - mi)*(ma - bMin);

	int rMin = INF;
	sort(v.begin(), v.end());
	for (int i = 0; i < N - 1; i++)
	{
		rMax = max(rMax, v[i].second);
		rMin = min(rMin, v[i].second);
		ans = min(ans, (rMax - min(rMin, v[i + 1].first))*(ma - mi));
	}
	printf("%lld\n", ans);
	return 0;
}

Submission Info

Submission Time
Task E - Ball Coloring
User winjii
Language C++14 (GCC 5.4.1)
Score 700
Code Size 988 Byte
Status AC
Exec Time 176 ms
Memory 3328 KiB

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 173 ms 3328 KiB
div21 AC 173 ms 3328 KiB
div22 AC 174 ms 3328 KiB
div23 AC 174 ms 3328 KiB
div24 AC 174 ms 3328 KiB
example0 AC 1 ms 256 KiB
example1 AC 1 ms 256 KiB
example2 AC 1 ms 256 KiB
maxrand0 AC 172 ms 3328 KiB
maxrand1 AC 173 ms 3328 KiB
maxrand2 AC 172 ms 3328 KiB
maxrand20 AC 171 ms 3328 KiB
maxrand21 AC 174 ms 3328 KiB
maxrand210 AC 174 ms 3328 KiB
maxrand211 AC 175 ms 3328 KiB
maxrand22 AC 176 ms 3328 KiB
maxrand23 AC 176 ms 3328 KiB
maxrand24 AC 174 ms 3328 KiB
maxrand25 AC 175 ms 3328 KiB
maxrand26 AC 176 ms 3328 KiB
maxrand27 AC 175 ms 3328 KiB
maxrand28 AC 175 ms 3328 KiB
maxrand29 AC 174 ms 3328 KiB
maxrand3 AC 172 ms 3328 KiB
maxrand4 AC 172 ms 3328 KiB
smallrand0 AC 1 ms 256 KiB
smallrand1 AC 1 ms 256 KiB
smallrand2 AC 1 ms 256 KiB
smallrand3 AC 1 ms 256 KiB
smallrand4 AC 1 ms 256 KiB
sparse0 AC 171 ms 3328 KiB
sparse1 AC 172 ms 3328 KiB
sparse2 AC 172 ms 3328 KiB
sparse3 AC 172 ms 3328 KiB
sparse4 AC 173 ms 3328 KiB