#include #include #include #include #include using namespace std; struct run_info { int size; // number of elements. vector disp; // displacements vector load; // loads }; typedef map InfoMap; typedef vector DispVector; typedef vector LoadVector; int main() { InfoMap runs; for(string line; getline(cin, line); ) { if(line.empty()) continue; string tmp; int run, num, disp; float load; stringstream ss(line); ss >> run >> num >> tmp >> disp >> load; pair x = runs.insert(make_pair(run, run_info())); run_info& inf = x.first->second; inf.size = max(inf.size, num); inf.disp.push_back(disp); inf.load.push_back(load); } // Informatics to compute. // - Average load before fail // - Average elements before fail // - load to displacement typedef pair Count; typedef std::map> LoadToDisp; LoadToDisp l2d; for(InfoMap::iterator i = runs.begin(); i != runs.end(); ++i) { run_info& inf = i->second; for(size_t j = 0; j < inf.load.size(); ++j) { int l = int(inf.load[j] * 100); Count& cnt = l2d[l]; cnt.first++; cnt.second += inf.disp[j]; } } for(LoadToDisp::iterator i = l2d.begin(); i != l2d.end(); ++i) { Count& cnt = i->second; cnt.second /= double(cnt.first); cout << float(i->first / 100.0f) << "\t" << cnt.second << "\n"; // cout << float(i->first / 100.0f) << "\t" << cnt.second << "\t" << cnt.first << "\n"; } return 0; }