結果

問題 No.180 美しいWhitespace (2)
ユーザー 158b158b
提出日時 2015-05-24 12:55:11
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,324 bytes
コンパイル時間 436 ms
コンパイル使用メモリ 65,736 KB
実行使用メモリ 8,056 KB
最終ジャッジ日時 2023-09-20 11:13:50
合計ジャッジ時間 13,703 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <limits.h>
#include <vector>
#include <numeric>
using namespace std;


int main(){
	int n;
	//y=ax+b
	long b[1000];	//スペース
	long a[1000];	//タブ
	long y[1000];	//相対位置
	long x;
	long ansx,ansy;
	int maxno,minno;
	int targetmax = 0;	//該当の最初の位置
	int targetmin = 0;	//該当の最初の位置
	long temp;
	
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> b[i] >> a[i];
		if(a[i] > a[targetmax] || a[i] == a[targetmax] && b[i] > b[targetmax]){
			targetmax = i;
		}
		if(a[i] < a[targetmin] || a[i] == a[targetmin] && b[i] < b[targetmax]){
			targetmin = i;
		}
	}
	
	//相対位置計算
	for(int i=0; i<n; i++){
		y[i] = b[i] - b[targetmax];
	}
	
	//醜さ計算
	maxno = max_element(y, y + n) - y;
	minno = min_element(y, y + n) - y;
	ansx = 0;
	ansy = *(maxno + y) - *(minno + y);
	
	x = 0;
	while(maxno != targetmax && minno != targetmin){
		//タブ幅を進める
		x ++;
		
		//相対位置計算
		for(int i=0; i<n; i++){
			y[i] += a[i] - a[targetmax];
		}
		
		//醜さ計算
		maxno = max_element(y, y + n) - y;
		minno = min_element(y, y + n) - y;
		temp = *(maxno + y) - *(minno + y);
		
		//ans更新
		if(temp < ansy){
			ansy = temp;
			ansx = x;
		}
	}
	
	cout << ansx << endl;
	return 0;
}
0