結果
| 問題 |
No.662 スロットマシーン
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-03-21 23:05:32 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 5 ms / 2,000 ms |
| コード長 | 1,679 bytes |
| コンパイル時間 | 770 ms |
| コンパイル使用メモリ | 76,960 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-24 19:42:45 |
| 合計ジャッジ時間 | 1,562 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 |
ソースコード
#include <iostream>
#include <vector>
#include <string>
#include <iomanip>
using namespace std;
int checkPic(string &tmp, vector<string> &coinNameArray);
int main() {
double expectValue = 0;
double tmpExpect = 0;
unsigned int coin;
string coinName;
vector<string> coinNameArray(5);
vector<unsigned int> coinNumber(5);
unsigned int n[3];
string tmpPic;
vector<vector<string>> leel;
vector<vector<unsigned int>> picNumber(3, vector<unsigned int>(5));
leel.resize(3);
unsigned long long matchPattern[5]={0, 0, 0, 0, 0};
for(int i=0; i<5; i++)
{
cin>>coinName>>coin;
coinNameArray[i] = coinName;
coinNumber[i]=coin;
}
for (int i = 0; i < 3; i++)
{
cin >> n[i];
leel[i].resize(n[i]);
for (int j = 0; j < n[i]; j++)
{
cin >> tmpPic;
picNumber[i][checkPic(tmpPic, coinNameArray)]++;
leel[i][j]=tmpPic;
}
}
for(int i=0; i<5; i++)
{
tmpExpect= ((picNumber[0][i]/(double)n[0])*(picNumber[1][i]/(double)n[1])*(picNumber[2][i]/(double)n[2])*(double)coinNumber[i]);
expectValue += tmpExpect;
matchPattern[i] = (unsigned long long)picNumber[0][i]*(unsigned long long)picNumber[1][i]*(unsigned long long)picNumber[2][i]*(unsigned long long)5;
}
expectValue *= 5.0;
cout<<setprecision(7)<<expectValue<<endl;
for (unsigned long long i : matchPattern)
cout<< i <<endl;
return 0;
}
int checkPic(string &tmp, vector<string> &coinNameArray)
{
for(int i=0; i<5; i++)
{
if(tmp == coinNameArray[i])
return i;
}
return 0;
}