結果
問題 |
No.647 明太子
|
ユーザー |
|
提出日時 | 2018-11-09 04:42:23 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,640 bytes |
コンパイル時間 | 729 ms |
コンパイル使用メモリ | 69,400 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-21 05:03:30 |
合計ジャッジ時間 | 2,129 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 WA * 1 |
other | AC * 17 WA * 3 |
ソースコード
#include<iostream> #include<vector> #include<algorithm> using namespace std; struct Person{ int price=0; int spice = 0; }; struct Mentaiko { int price = 0; int spice = 0; }; int main() { //整数nの入力 //データの入力 //整数mの入力 //データの入力 //大きさmの配列countを用意 //ループ開始 //ループ開始 //i番目の金額以内かつ、i番目の辛さ以上であればカウントする //0~mまで繰り返す //0~nまで繰り返す int n = 0, m = 0; vector<Person> array1; vector<Mentaiko> array2; cin >> n; for (int i = 0;i < n;i++) { Person buff; cin >> buff.price >> buff.spice; array1.push_back(buff); } cin >> m; for (int i = 0;i < m;i++) { Mentaiko buff; cin >> buff.price >> buff.spice; array2.push_back(buff); } vector<int> count(m, 0); for (int i = 0;i < n;i++) { for (int j = 0;j < m;j++) { if (array1[i].price >= array2[j].price && array1[i].spice <= array2[j].spice)count[j]++; } } vector<int>::iterator itr1= max_element(count.begin(), count.end());//最大値のイテレータ int maxvalue = *max_element(count.begin(), count.end());//最大値 size_t maxIndex = distance(count.begin(), itr1);//最大値のインデックス vector<int> indexs; indexs.push_back(maxIndex); vector<int>::iterator itr2; while (true) { if (itr1 != count.end()-1 && *max_element(itr1+1, count.end()) == maxvalue) { itr2 = max_element(itr1+1, count.end()); maxIndex = distance(count.begin(), itr2); indexs.push_back(maxIndex); itr1 = itr2; } else break; } for (int i : indexs) { cout << i+1<<endl; } return 0; }