結果
問題 |
No.24 数当てゲーム
|
ユーザー |
|
提出日時 | 2019-04-11 11:39:44 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 802 bytes |
コンパイル時間 | 633 ms |
コンパイル使用メモリ | 67,084 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-18 09:07:26 |
合計ジャッジ時間 | 1,080 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 |
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:43:13: warning: 'sub' may be used uninitialized [-Wmaybe-uninitialized] 43 | cout << sub << endl; | ^~~ main.cpp:13:9: note: 'sub' was declared here 13 | int sub; | ^~~
ソースコード
#include <iostream> #include <string> using namespace std; int main() { int n; int a[10][4]; string s[10]; int cnt[10] = {}; int max = -10000100; int sub; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i][0] >> a[i][1] >> a[i][2] >> a[i][3] >> s[i]; } for (int i = 0; i < n; i++) { if (s[i] == "YES") { cnt[a[i][0]]++; cnt[a[i][1]]++; cnt[a[i][2]]++; cnt[a[i][3]]++; } else { cnt[a[i][0]]--; cnt[a[i][1]]--; cnt[a[i][2]]--; cnt[a[i][3]]--; } } for (int i = 0; i <= 9; i++) { if (cnt[i] > max) { max = cnt[i]; sub = i; } } cout << sub << endl; }