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