結果
| 問題 |
No.180 美しいWhitespace (2)
|
| ユーザー |
kuuso1
|
| 提出日時 | 2015-04-06 00:50:51 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,640 bytes |
| コンパイル時間 | 1,005 ms |
| コンパイル使用メモリ | 115,956 KB |
| 実行使用メモリ | 28,192 KB |
| 最終ジャッジ日時 | 2024-07-04 03:00:01 |
| 合計ジャッジ時間 | 2,851 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 WA * 1 |
| other | AC * 13 WA * 18 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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);
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));}
}
kuuso1