Submission #2240768


Source Code Expand

#include <algorithm>
#include <cstdio>
typedef long long ll; 
int a[200005], b[200005], idx[200005]; 
inline bool comp(int x, int y)
{
	return a[x] < a[y]; 
}
int main()
{
	// freopen("ARC073-E.in", "r", stdin); 
	int n, mx = 0, mn = 1e9, mn_opp, mx_opp; 
	scanf("%d", &n); 
	for (int i = 0; i < n; i++)
	{
		scanf("%d%d", a + i, b + i); 
		idx[i] = i; 
		if (a[i] > b[i])
			std::swap(a[i], b[i]); 
		if (a[i] < mn)
		{
			mn = a[i]; 
			mn_opp = b[i]; 
		}
		if (b[i] > mx)
		{
			mx = b[i]; 
			mx_opp = a[i]; 
		}
	}
	int cur_mx = mx_opp, cur_mn = mn_opp; 
	for (int i = 0; i < n; i++)
	{
		cur_mx = std::max(cur_mx, a[i]); 
		cur_mn = std::min(cur_mn, b[i]); 
	}
	ll ans = (ll)(mx - cur_mn) * (cur_mx - mn); 
	std::sort(idx, idx + n, comp); 
	int cur = 1e9;
	for (int i = 0; i < n; i++)
	{
		ans = std::min(ans, (ll)(mx - mn) * (cur_mx - std::min(a[idx[i]], cur))); 
		cur = std::min(cur, b[idx[i]]); 
		cur_mx = std::max(cur_mx, b[idx[i]]); 
	}
	printf("%lld\n", ans);
	return 0; 
}

Submission Info

Submission Time
Task E - Ball Coloring
User diamond_duke
Language C++14 (GCC 5.4.1)
Score 700
Code Size 1037 Byte
Status AC
Exec Time 69 ms
Memory 2560 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:13:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n); 
                 ^
./Main.cpp:16:30: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", a + i, b + i); 
                              ^

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 68 ms 2560 KB
div21 AC 68 ms 2560 KB
div22 AC 69 ms 2560 KB
div23 AC 68 ms 2560 KB
div24 AC 69 ms 2560 KB
example0 AC 0 ms 128 KB
example1 AC 0 ms 128 KB
example2 AC 0 ms 128 KB
maxrand0 AC 69 ms 2560 KB
maxrand1 AC 69 ms 2560 KB
maxrand2 AC 69 ms 2432 KB
maxrand20 AC 55 ms 2560 KB
maxrand21 AC 60 ms 2560 KB
maxrand210 AC 53 ms 2560 KB
maxrand211 AC 59 ms 2560 KB
maxrand22 AC 61 ms 2560 KB
maxrand23 AC 63 ms 2432 KB
maxrand24 AC 69 ms 2560 KB
maxrand25 AC 57 ms 2560 KB
maxrand26 AC 56 ms 2560 KB
maxrand27 AC 63 ms 2560 KB
maxrand28 AC 66 ms 2560 KB
maxrand29 AC 68 ms 2560 KB
maxrand3 AC 69 ms 2560 KB
maxrand4 AC 68 ms 2432 KB
smallrand0 AC 1 ms 128 KB
smallrand1 AC 1 ms 128 KB
smallrand2 AC 1 ms 128 KB
smallrand3 AC 1 ms 128 KB
smallrand4 AC 1 ms 128 KB
sparse0 AC 58 ms 2560 KB
sparse1 AC 60 ms 2560 KB
sparse2 AC 58 ms 2560 KB
sparse3 AC 58 ms 2560 KB
sparse4 AC 58 ms 2560 KB