結果
問題 | No.180 美しいWhitespace (2) |
ユーザー | nablaenergy_21 |
提出日時 | 2015-04-14 14:20:40 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 931 bytes |
コンパイル時間 | 228 ms |
コンパイル使用メモリ | 24,192 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-04 14:28:40 |
合計ジャッジ時間 | 1,168 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | AC | 0 ms
5,376 KB |
testcase_02 | AC | 1 ms
5,376 KB |
testcase_03 | AC | 0 ms
5,376 KB |
testcase_04 | AC | 1 ms
5,376 KB |
testcase_05 | AC | 1 ms
5,376 KB |
testcase_06 | AC | 1 ms
5,376 KB |
testcase_07 | AC | 1 ms
5,376 KB |
testcase_08 | AC | 1 ms
5,376 KB |
testcase_09 | AC | 2 ms
5,376 KB |
testcase_10 | AC | 2 ms
5,376 KB |
testcase_11 | AC | 2 ms
5,376 KB |
testcase_12 | AC | 2 ms
5,376 KB |
testcase_13 | AC | 2 ms
5,376 KB |
testcase_14 | AC | 2 ms
5,376 KB |
testcase_15 | AC | 2 ms
5,376 KB |
testcase_16 | AC | 2 ms
5,376 KB |
testcase_17 | AC | 2 ms
5,376 KB |
testcase_18 | AC | 2 ms
5,376 KB |
testcase_19 | AC | 2 ms
5,376 KB |
testcase_20 | AC | 1 ms
5,376 KB |
testcase_21 | AC | 1 ms
5,376 KB |
testcase_22 | AC | 1 ms
5,376 KB |
testcase_23 | AC | 0 ms
5,376 KB |
testcase_24 | AC | 1 ms
5,376 KB |
testcase_25 | AC | 1 ms
5,376 KB |
testcase_26 | AC | 1 ms
5,376 KB |
testcase_27 | AC | 1 ms
5,376 KB |
testcase_28 | AC | 1 ms
5,376 KB |
testcase_29 | AC | 0 ms
5,376 KB |
testcase_30 | AC | 2 ms
5,376 KB |
testcase_31 | AC | 2 ms
5,376 KB |
testcase_32 | AC | 2 ms
5,376 KB |
testcase_33 | AC | 1 ms
5,376 KB |
testcase_34 | AC | 1 ms
5,376 KB |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:32:16: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘long long int*’ [-Wformat=] 32 | scanf("%I64d",&N); | ~~~~^ ~~ | | | | | long long int* | int* | %I64lld main.cpp:34:20: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘long long int*’ [-Wformat=] 34 | scanf("%I64d %I64d",&a[i],&b[i]); | ~~~~^ ~~~~~ | | | | int* long long int* | %I64lld main.cpp:34:26: warning: format ‘%d’ expects argument of type ‘int*’, but argument 3 has type ‘long long int*’ [-Wformat=] 34 | scanf("%I64d %I64d",&a[i],&b[i]); | ~~~~^ ~~~~~ | | | | int* long long int* | %I64lld main.cpp:52:17: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long long int’ [-Wformat=] 52 | printf("%I64d\n",ans); | ~~~~^ ~~~ | | | | int long long int | %I64lld main.cpp:32:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 32 | scanf("%I64d",&N); | ~~~~~^~~~~~~~~~~~ main.cpp:34:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 34 | scanf("%I64d %I64d",&a[i],&b[i]); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h> long long N; long long a[1000],b[1000]; long long i,s,t,u,v,ans; long long min(long long a, long long b){ if(a>b){return b;}else{return a;} } long long max(long long a, long long b){ if(a>b){return a;}else{return b;} } long long ugly(long long x){ long long mi,ma; mi = 1000000000000000000; ma = 0; for(i=0;i<N;i++){ mi = min(mi, a[i] + b[i] * x); ma = max(ma, a[i] + b[i] * x); } return ma - mi; } int main(void){ scanf("%I64d",&N); for(i=0;i<N;i++){ scanf("%I64d %I64d",&a[i],&b[i]); } s = 1; t = 1000000000; while(t-s>2){ u = (2*s + t)/3; v = (s + 2*t)/3; if(ugly(u)<=ugly(v)){t = v;}else{s = u;} } if(ugly(s)<=ugly(s+1) && ugly(s)<=ugly(s+2)){ ans = s; }else if(ugly(s+1)<=ugly(s) && ugly(s+1)<=ugly(s+2)){ ans = s+1; }else{ ans = s+2; } printf("%I64d\n",ans); }