結果
問題 | No.706 多眼生物の調査 |
ユーザー |
|
提出日時 | 2019-08-01 00:17:12 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 13 ms / 2,000 ms |
コード長 | 496 bytes |
コンパイル時間 | 2,144 ms |
コンパイル使用メモリ | 192,300 KB |
最終ジャッジ日時 | 2025-01-07 10:23:01 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 5 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:19:36: warning: ‘ans’ may be used uninitialized [-Wmaybe-uninitialized] 19 | } else if (cnt[eyes] == mx && eyes > ans) { | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~ main.cpp:10:9: note: ‘ans’ was declared here 10 | int ans; | ^~~
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { int n; cin >> n; int cnt[1000] {}; int mx = 0; int ans; for (int i = 0; i < n; i++) { string s; cin >> s; int eyes = s.size() - 2; cnt[eyes]++; if (cnt[eyes] > mx) { mx = cnt[eyes]; ans = eyes; } else if (cnt[eyes] == mx && eyes > ans) { ans = eyes; } } cout << ans << endl; return 0; }