Problem p01315 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef ostringstream OSS;
typedef istringstream ISS;

typedef vector<int> VI;
typedef vector<VI> VVI;

typedef long long LL;

typedef pair<int, int> PII;
typedef vector<PII> VPII;

#define X first
#define Y second

const LL MOD = 1000000007;

template <typename T> void dump(T a, int n) {
  for (int i = 0; i < n; i++)
    cout << a[i] << (i == n - 1 ? '\\n' : ' ');
}

template <typename T> void dump(T a) { dump<T>(a, a.size()); }

bool mycomp(pair<double, string> a, pair<double, string> b) {
  if (a.first != b.first)
    return a.first > b.first;
  return a.second < b.second;
}

int main(void) {
  int N;
  while (cin >> N, N) {
    vector<pair<double, string>> list(N);

    for (auto &x : list) {
      string name;
      int cost;
      int time = 0;
      int time2 = 0;
      int seed;
      int price;
      int loop;

      cin >> name;
      cin >> cost;
      for (int j = 0, temp; j < 5; j++) {
        cin >> temp;
        time += temp;
        if (j >= 3) {
          time2 += temp;
        }
      }
      cin >> seed >> price >> loop;

      double effis =
          1. * (price * seed * loop - cost) / (time + (time2 * (loop - 1)));

      x.first = effis;
      x.second = name;
    }

    sort(list.begin(), list.end(), mycomp);

    for (auto &x : list) {
      cout << x.second << endl;
    }

    cout << "#" << endl;
  }

  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef ostringstream OSS;
typedef istringstream ISS;

typedef vector<int> VI;
typedef vector<VI> VVI;

typedef long long LL;

typedef pair<int, int> PII;
typedef vector<PII> VPII;

#define X first
#define Y second

const LL MOD = 1000000007;

template <typename T> void dump(T a, int n) {
  for (int i = 0; i < n; i++)
    cout << a[i] << (i == n - 1 ? '\\n' : ' ');
}

template <typename T> void dump(T a) { dump<T>(a, a.size()); }

int main(void) {
  int N;
  while (cin >> N, N) {
    vector<pair<double, string>> list(N);

    for (int i = 0; i < N; i++) {
      string name;
      int cost;
      VI times(5);
      int seed;
      int price;
      int loop;

      cin >> name;
      cin >> cost;
      for (int j = 0; j < 5; j++) {
        cin >> times[i];
      }
      cin >> seed >> price >> loop;

      list[i].first = 1. * accumulate(times.begin(), times.end(), 0) * loop /
                      (price * seed * loop - cost);
      list[i].second = name;
    }

    sort(list.begin(), list.end());

    for (int i = 0; i < N; i++) {
      cout << list[i].second << endl;
    }

    cout << "#" << endl;
  }

  return 0;
}