結果
問題 | No.1132 凸凹 |
ユーザー |
![]() |
提出日時 | 2020-08-04 23:26:01 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 770 bytes |
コンパイル時間 | 2,123 ms |
コンパイル使用メモリ | 191,980 KB |
最終ジャッジ日時 | 2025-01-12 14:28:14 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 26 |
ソースコード
#include <bits/stdc++.h> using namespace std; const int INF = 1 << 30; template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; } template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; } int main() { ios::sync_with_stdio(false); cin.tie(0); int a, b, c, d, p, q; cin >> a >> b >> c >> d >> p >> q; auto f = [a, b, c, d](int x) { return a * x * x * x + b * x * x + c * x + d; }; int ax = -INF, ay = -INF, bx = INF, by = INF; for (int i = p; i < q + 1; i++) { if (chmax(ay, f(i))) { ax = i; } if (chmin(by, f(i))) { bx = i; } } cout << ay << ' ' << ax << ' ' << by << ' ' << bx << '\n'; return 0; }