結果

問題 No.180 美しいWhitespace (2)
ユーザー ry0u_ydry0u_yd
提出日時 2015-04-06 00:32:27
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,044 bytes
コンパイル時間 432 ms
コンパイル使用メモリ 62,888 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-17 04:58:22
合計ジャッジ時間 5,997 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 3 ms
4,376 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 WA -
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 2 ms
4,376 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 2 ms
4,376 KB
testcase_33 WA -
testcase_34 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30

using namespace std;
typedef long long ll;

int main()
{
	int n;
	cin >> n;

	vector<ll> A(n),B(n);
	ll vmax = 0,max_i = 0,vmin = INF,min_i = 0;
	rep(i,n)
	{
		cin >> A[i] >> B[i];
		
		if(vmax < A[i] + B[i])
		{
			vmax = A[i] + B[i];
			max_i = i;
		}
		else if(vmax == A[i] + B[i])
		{
			if(B[max_i] < B[i])
			{
				vmax = A[i] + B[i];
				max_i = i;
			}
		}

		if(vmin > A[i] + B[i])
		{
			vmin = A[i] + B[i];
			min_i = i;
		}
		else if(vmin == A[i] + B[i])
		{
			if(B[min_i] > B[i])
			{
				vmin = A[i] + B[i];
				min_i = i;
			}
		}
	}

	ll x = 1;
	ll res = vmax - vmin;
	while(true)
	{
		if(vmax + B[max_i] - (vmin + B[min_i]) < res)
		{
			vmax += B[max_i];
			vmin += B[min_i];
						
			if(vmax < vmin)
			{
				swap(vmax,vmin);
				swap(max_i,min_i);
			}
			
			res = vmax - vmin;
			x++;

		}
		else break;
	}

	cout << x << endl;

	
		return 0;
}
0