結果
問題 | No.180 美しいWhitespace (2) |
ユーザー |
|
提出日時 | 2016-02-18 04:42:22 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,389 bytes |
コンパイル時間 | 1,301 ms |
コンパイル使用メモリ | 161,972 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-22 07:47:00 |
合計ジャッジ時間 | 2,343 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 3 |
other | AC * 9 WA * 22 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:55:9: warning: ‘from’ may be used uninitialized in this function [-Wmaybe-uninitialized] 55 | if (from != amin){ | ^~
ソースコード
#include "bits/stdc++.h" #include<unordered_map> #pragma warning(disable:4996) using namespace std; using ld = long double; template<class T> using Table = vector<vector<T>>; vector<long long >as,bs; long long check(const int tab){ long long amin = as[0] + bs[0] * tab; long long amax = as[0] + bs[0] * tab; for (int i = 1; i < as.size(); ++i){ long long len = as[i] + bs[i] * tab; amin = min(amin, len); amax = max(amax, len); } return amax-amin; } int main() { int N; cin >> N; as.resize(N); bs.resize(N); for (int i = 0; i < N; ++i){ cin >> as[i] >> bs[i]; } long long amin = 0; long long amax = 5e9; { int num = 50; while (num--, num){ long long amid0 = (amin * 2 + amax) / 3; long long amid1 = (amin + amax * 2) / 3; if (check(amid0) < check(amid1)){ amax = amid1; } else{ amin = amid0; } } } long long anslen = check(amin); for (long long i = amin; i < amax; ++i){ anslen = min(check(i), anslen); } long long from; for (long long i = amin; i < amax; ++i){ if (anslen == check(i)){ from = i; break; } } if (from != amin){ cout << from << endl; return 0; }else { long long amin = 0; long long amax = from; while (amin+1!=amax){ long long amid = (amin + amax) / 2; if (check(amid) == anslen){ amax = amid; } else{ amin = amid; } } cout << amax << endl; } return 0; }