結果

問題 No.73 helloworld
ユーザー ふーらくたるふーらくたる
提出日時 2016-08-13 04:55:57
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 834 bytes
コンパイル時間 400 ms
コンパイル使用メモリ 52,116 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-12 01:08:51
合計ジャッジ時間 1,223 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:27:51: warning: ‘d’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     ll temp_res = h * e * func_for_o(o) * w * r * d,
                                                   ^
main.cpp:27:45: warning: ‘r’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     ll temp_res = h * e * func_for_o(o) * w * r * d,
                   ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
main.cpp:27:41: warning: ‘w’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     ll temp_res = h * e * func_for_o(o) * w * r * d,
                   ~~~~~~~~~~~~~~~~~~~~~~^~~
main.cpp:7:18: warning: ‘o’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     return o_cnt / 2 * (o_cnt - o_cnt / 2);
            ~~~~~~^~~
main.cpp:11:17: note: ‘o’ was declared here
     ll h, e, l, o, w, r, d;
                 ^
main.cpp:30:32: warning: ‘l’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     for (ll left_l = 2; left_l <= l - 1; left_l++) {
                         ~~~~~~~^~~~~~~~
main.cpp:27:21: warning: ‘e’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     ll temp_res = h * e * func_for_o(o) * w * r * d,
                   ~~^~~
main.cpp:27:21: warning: ‘h’ may be used uninitialized in this function [-Wmaybe-uninitialized]

ソースコード

diff #

#include <iostream>
using namespace std;

typedef long long ll;

ll func_for_o(ll o_cnt) {
    return o_cnt / 2 * (o_cnt - o_cnt / 2);
}

int main() {
    ll h, e, l, o, w, r, d;
    for (int i = 0; i < 26; i++) {
        ll c;
        cin >> c;
        switch ('a' + i) {
        case 'h': h = c; break;
        case 'e': e = c; break;
        case 'l': l = c; break;
        case 'o': o = c; break;
        case 'w': w = c; break;
        case 'r': r = c; break;
        case 'd': d = c; break;
        default: break;
        }
    }

    ll temp_res = h * e * func_for_o(o) * w * r * d,
       res = 0;
    // l だけ全探索
    for (ll left_l = 2; left_l <= l - 1; left_l++) {
        ll temp = left_l * (left_l - 1) / 2 * (l - left_l);
        res = max(res, temp_res * temp);
    }
    cout << res << endl;

    return 0;
}
0