結果

問題 No.180 美しいWhitespace (2)
ユーザー kuuso1kuuso1
提出日時 2015-04-06 01:04:40
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,695 bytes
コンパイル時間 3,499 ms
コンパイル使用メモリ 105,088 KB
実行使用メモリ 24,824 KB
最終ジャッジ日時 2023-09-17 05:44:36
合計ジャッジ時間 6,793 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
18,692 KB
testcase_01 WA -
testcase_02 AC 57 ms
20,688 KB
testcase_03 AC 58 ms
20,660 KB
testcase_04 AC 59 ms
20,672 KB
testcase_05 WA -
testcase_06 AC 59 ms
22,856 KB
testcase_07 AC 60 ms
20,824 KB
testcase_08 AC 61 ms
20,764 KB
testcase_09 AC 64 ms
20,752 KB
testcase_10 AC 62 ms
20,816 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 62 ms
20,848 KB
testcase_20 AC 58 ms
22,772 KB
testcase_21 WA -
testcase_22 AC 57 ms
18,820 KB
testcase_23 WA -
testcase_24 AC 57 ms
20,872 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 58 ms
22,820 KB
testcase_30 AC 61 ms
20,732 KB
testcase_31 WA -
testcase_32 AC 61 ms
22,780 KB
testcase_33 WA -
testcase_34 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		double right=1e9+10;
		double left=0.0;
		
		for(int t=0;t<100;t++){
			if (f((left * 2 + right) / 3) < f((left + right * 2) / 3)){
				right = (left + right * 2) / 3;
			} else {
				left = (left * 2 + right) / 3;
			}
		}
		int x=(int)((right+left)*0.5);
//Console.WriteLine(x);
		if(x==(int)1e9){
			Console.WriteLine(1);return;
		}
		int ans=-1;
		double val=4e9;
		for(int i=x-3;i<x+3;i++){
			if(i<=0)continue;
			if(f((double)i)<val){
				val=f(i);
				ans=i;
			}
		}
		
		Console.WriteLine(ans<=0?1:ans);
		
		
	}
	double f(double x){
		double max=-1.0;
		double min=2e9;
		for(int i=0;i<N;i++){
			double c=(double)A[i]+(double)B[i]*x;
			max=Math.Max(max,c);
			min=Math.Min(min,c);
		}
		return max-min;
	}
	
	int N;
	int[] A;
	int[] B;
	public Sol(){
		N=ri();
		A=new int[N];
		B=new int[N];
		for(int i=0;i<N;i++){
			var d=ria();
			A[i]=d[0];B[i]=d[1];
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(){return Console.ReadLine().Split(' ');}
	static int[] ria(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));}
	static long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));}
	static double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));}
}
0