alexjercan/bugnet huggingface dataset:
Problem p00033 (C++) — buggy submission, verdict: Time Limit Exceeded

/*0ms,1008KB*/

#include <cstdio>
#include <cstring>

int a[15], l[15], r[15], t, i, j, lc, rc, cnt;
bool vis[15], flag;

bool solve() {
  for (i = 0; i < 1024; ++i) {
    memset(l, 0, sizeof(l));
    memset(r, 0, sizeof(r));
    lc = rc = 0;
    for (cnt = 0, j = i; cnt < 10; ++cnt, j >>= 1) {
      if (j & 1)
        l[lc++] = a[cnt];
      else
        r[rc++] = a[cnt];
    }
    flag = true;
    for (j = 1; j < lc; ++j)
      if (l[j] < l[j - 1]) {
        flag = false;
        break;
      }
    if (flag)
      for (j = 1; j < rc; ++j)
        if (r[j - 1] > r[j]) {
          flag = false;
          break;
        }
    if (flag)
      return true;
  }
  return false;
}

int main() {
  scanf("%d", &t);
  while (t--) {
    memset(vis, 0, sizeof(vis));
    for (i = 0; i < 10; ++i)
      scanf("%d", &a[i]);
    puts(solve() ? "YES" : "NO");
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

#define MAX_W 100
#define MAX_H 100

char room[MAX_W][MAX_H];
int W, H;

const int direc[4][2] = {
    {0, -1},
    {1, 0},
    {0, 1},
    {-1, 0},
};

void dfs(const int &row, const int &col, const char c);

int main() {
  while (cin >> H >> W, W > 0) {
    int step = 0;
    int col, row;
    for (row = 0; row < H; ++row) {
      for (col = 0; col < W; ++col) {
        cin >> room[row][col];
      }
    }
    for (row = 0; row < H; ++row) {
      for (col = 0; col < W; ++col) {
        if (room[row][col] != '!') {
          dfs(row, col, room[row][col]);
          ++step;
        }
      }
    }
    cout << step << endl;
  }
  return 0;
}

void dfs(const int &row, const int &col, const char c) {
  room[row][col] = '!';
  for (int d = 0; d < 4; ++d) {
    int curRow = row + direc[d][1];
    int curCol = col + direc[d][0];
    if (curRow >= 0 && curRow < H && curCol >= 0 && curCol < W &&
        room[curRow][curCol] == c) {
      dfs(curRow, curCol, c);
    }
  }
}
Problem p00033 (C++) — buggy submission, verdict: Runtime Error

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
// 思路：先dfs出一个??数?A，剩下的?成一个数?B，判断B数?是否??即可。
using namespace std;
int t[11];
int v[11];
void dfs(int x, int y) {
  if (t[x] < t[y] && y < 10) {
    v[y] = 1;
    dfs(y, y + 1);
  } else if (t[x] > t[y] && y < 10) {
    dfs(x, y + 1);
  }
}
int main() {
  int n, flag = 0;
  scanf("%d", &n);
  while (n--) {
    memset(t, 0, sizeof(t));

    // 初始化
    for (int i = 0; i < 10; i++)
      scanf("%d", &t[i]);
    for (int i = 0; i < 10; i++) // i<9??
    {
      memset(v, 0, sizeof(v));
      v[i] = 1;
      dfs(i, i + 1);
      int aa = 0;
      flag = 0;
      for (int i = 0; i < 10; i++) {
        if (v[i] == 0) {
          if (aa > t[i]) {
            flag = 1;
            break;
          } else
            aa = t[i];
        }
      }
      if (flag == 0) {
        cout << "YES" << endl;
        break;
      }
    }
    if (flag == 1)
      cout << "NO" << endl;
  }
}

Error: -11

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <stack>
#include <vector>

using namespace std;
int t[11];
vector<int> a;
vector<int> b;
int aa, bb;
bool solve() {
  for (int i = 0; i < 1 << 10; i++) {
    a.clear(), aa = 0;
    b.clear(), bb = 0;
    for (int j = 0; j < 10; j++) {
      if (i & (1 << j))
        a.push_back(t[j]);
      else
        b.push_back(t[j]);
    }
    int l1 = a.size();
    int l2 = b.size();
    for (int i = 0; i < (a.size() - 1); i++) {
      if (a[i] > a[i + 1])

      {
        aa = 1;
        break;
      }
    }

    for (int i = 0; i < l2 - 1; i++) {
      if (b[i] > b[i + 1]) {
        bb = 1;
        break;
      }
    }

    if (aa == 0 && bb == 0) {
      return true;
    }
  }

  return false;
}
int main() {
  int n;
  scanf("%d", &n);
  while (n--) {
    a.clear();
    aa = 0;
    b.clear();
    bb = 0;
    memset(t, 0, sizeof(t));
    for (int i = 0; i < 10; i++) {
      scanf("%d", &t[i]);
    }

    if (solve())
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}
Problem p00034 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int main() {
  int l[10], v1, v2, len, point, now;
  while (scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", &l[0], &l[1], &l[2],
               &l[3], &l[4], &l[5], &l[6], &l[7], &l[8], &l[9], &v1,
               &v2) != EOF) {
    len = 0;
    for (int i = 0; i < 10; i++) {
      len += l[i];
    }
    point = (v1 * len) / (v1 + v2) + ((v1 * len) % (v1 + v2) > 0);
    now = 0;
    for (int i = 0; i < 10; i++) {
      now += l[i];
      if (now >= point) {
        printf("%d\\n", i + 1);
        break;
      }
    }
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long l[10], v1, v2, len, point, now;
  while (scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", &l[0], &l[1], &l[2],
               &l[3], &l[4], &l[5], &l[6], &l[7], &l[8], &l[9], &v1, &v2)) {
    len = 0;
    for (int i = 0; i < 10; i++) {
      len += l[i];
    }
    // point=(v1*len)/(v1+v2)+((v1*len)%(v1+v2)>0);
    point = len * (v1 / (v1 + v2));
    now = 0;
    for (int i = 0; i < 10; i++) {
      now += l[i];
      if (now >= point) {
        cout << i + 1 << endl;
        break;
      }
    }
  }
  return 0;
}
Problem p00034 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;

int main() {
  int l[10], v1, v2;
  int len;

  while (scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", l, &l[1], &l[2], &l[3],
               &l[4], &l[5], &l[6], &l[7], &l[8], &l[9], &v1, &v2) != EOF) {
    len = 0;
    for (int i = 0; i < 10; i++) {
      len += l[i];
    }
    double t = (double)len / (v1 + v2);
    double d = (double)v1 * t;
    len = 0;
    for (int i = 0; i < 10; i++) {
      len += l[i];
      if (d <= len) {
        cout << i + 1 << endl;
        break;
      }
    }
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;

int main() {
  int l[10], v1, v2;
  int len;

  while (scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", l, &l[1], &l[2], &l[3],
               &l[4], &l[5], &l[6], &l[7], &l[8], &l[9], &v1, &v2)) {
    len = 0;
    for (int i = 0; i < 10; i++) {
      len += l[i];
    }
    double t = (double)len / (v1 + v2);
    double d = (double)v1 * t;
    len = 0;
    for (int i = 0; i < 10; i++) {
      len += l[i];
      if (d <= len) {
        cout << i + 1 << endl;
        break;
      }
    }
  }
}
Problem p00034 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int inf = 1000000000;

int main(void) {

  vector<int> l(10);
  vector<int> v(2);
  while (scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", &l[0], &l[1], &l[2],
               &l[3], &l[4], &l[5], &l[6], &l[7], &l[8], &l[9], &v[0],
               &v[1]) != EOF) {
    int sum = accumulate(l.begin(), l.end(), 0);
    // cerr << sum << " ";
    double tmp = sum * v[0] * 1.0 / (v[0] + v[1]);
    // cerr << tmp << endl;
    for (int i = 1; i < 10; i++)
      l[i] += l[i - 1];
    // int a = 0;
    for (int i = 1; i < 10; i++) {
      if (l[i - 1] == tmp) {
        cout << i << endl;
        break;
      } else if (l[i - 1] < tmp && tmp < l[i]) {
        // cerr << l[i-1] << " " << l[i] << endl;
        cout << i + 1 << endl;
        // break;
      }
    }
  }

  return 0;
}

// EOF

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int inf = 1000000000;

int main(void) {

  vector<int> l(10);
  vector<int> v(2);
  while (scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", &l[0], &l[1], &l[2],
               &l[3], &l[4], &l[5], &l[6], &l[7], &l[8], &l[9], &v[0], &v[1])) {
    int sum = accumulate(l.begin(), l.end(), 0);
    // cerr << sum << " ";
    double tmp = sum * v[0] * 1.0 / (v[0] + v[1]);
    // cerr << tmp << endl;
    for (int i = 1; i < 10; i++)
      l[i] += l[i - 1];
    // int a = 0;
    for (int i = 1; i < 10; i++) {
      if (l[i - 1] == tmp) {
        cout << i << endl;
        break;
      } else if (l[i - 1] < tmp && tmp < l[i]) {
        // cerr << l[i-1] << " " << l[i] << endl;
        cout << i + 1 << endl;
        // break;
      }
    }
  }

  return 0;
}

// EOF
Problem p00034 (C++) — buggy submission, verdict: Time Limit Exceeded

// 0034
// include-------------------------------------
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <stack>
#include <string>
#include <vector>

using namespace std;

// typedef--------------------------------------
typedef vector<int> VI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

#define MP make_pair

// repetition-----------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)

// constant-------------------------------------
const double PI = acos(-1.0);

// cout,cin-------------------------------------
#define COUT(x) cout << (x) << endl
#define CIN(x) cin >> (x)

int main() {

  int l[10], v1, v2;
  char a;

  while (cin >> l[0] >> a) {
    int L = 0;
    int ans = 0;
    int sum = 0;
    double x, k;

    FOR(i, 1, 10) {
      cin >> l[i] >> a;
      L += l[i];
    }
    cin >> v1 >> a >> v2;

    k = v1 * 1.0 / v2;
    x = 1.0 * L * k / (1 + k);

    while (sum < x) {
      sum += l[ans++];
    }

    COUT(ans);
  }

  return 0;
}

Error: TLE

Fixed submission:

// 0034
// include-------------------------------------
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <stack>
#include <string>
#include <vector>

using namespace std;

// typedef--------------------------------------
typedef vector<int> VI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

#define MP make_pair

// repetition-----------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)

// constant-------------------------------------
const double PI = acos(-1.0);

// cout,cin-------------------------------------
#define COUT(x) cout << (x) << endl
#define CIN(x) cin >> (x)

int main() {

  int l[10], v1, v2;

  while (1) {
    int L = 0;
    int ans = 0;
    int sum = 0;
    double x, k;
    char a;

    REP(i, 10) {
      cin >> l[i] >> a;
      L += l[i];
    }
    cin >> v1 >> a >> v2;

    k = v1 * 1.0 / v2;
    x = 1.0 * L * k / (1 + k);

    while (sum < x) {
      sum += l[ans++];
    }

    COUT(ans);
  }

  return 0;
}
Problem p00034 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
using namespace std;

#define SIZE 10

int main() {
  int l[SIZE] = {0}, v1, v2;
  double s;
  char t;
  while (scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", &l[0], &l[1], &l[2],
               &l[3], &l[4], &l[5], &l[6], &l[7], &l[8], &l[9], &v1,
               &v2) != EOF) {
    s = 0;
    for (int i = 0; i < SIZE; i++) {
      s += l[i];
    }
    s = s * v1 / (v1 + v2);

    for (int i = 0; i < 10; i++) {
      s -= l[i];
      if (s <= 0) {
        printf("%d\\n", i + 1);
        break;
      }
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

#define SIZE 10

int main() {
  int l[SIZE] = {0}, v1, v2;
  double s;
  char t;
  while (true) {
    for (int i = 0; i < SIZE; i++) {
      cin >> l[i];
      cin >> t;

      if (i == 0)
        continue;
      l[i] += l[i - 1];
    }
    cin >> v1 >> t >> v2;
    s = (double)l[SIZE - 1] / (v1 + v2);

    for (int i = 0; i < SIZE; i++) {
      if (l[i] >= s * v1) {
        cout << i + 1 << endl;
        break;
      }
    }
  }
  return 0;
}
Problem p00034 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cstdio>

using namespace std;
int main(void) {
  double a[10];
  double v[2];
  double ans;
  while (scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &a[0], &a[1],
               &a[2], &a[3], &a[4], &a[5], &a[6], &a[7], &a[8], &a[9], &v[0],
               &v[1]) != EOF) {
    double all = 0;
    double kari = 0;
    for (int i = 0; i < 10; i++)
      all += a[i];
    ans = (v[0] * all) / (v[0] + v[1]);
    if (ans == 0)
      printf("1\\n");
    else {
      for (int i = 0; i < 10; i++) {
        kari += a[i];
        if (kari >= ans) {
          printf("%d\\n", i + 1);
          break;
        }
      }
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cstdio>

using namespace std;
int main(void) {
  double load[10];
  double v[2];
  double ans;
  double all = 0;
  double kari = 0;
  while (1) {
    for (int i = 0; i < 10; i++) {
      scanf("%lf,", &load[i]);
      all += load[i];
    }
    scanf("%lf,%lf", &v[0], &v[1]);
    ans = (v[0] * all) / (v[0] + v[1]);
    if (ans == 0)
      printf("1\\n");
    else {
      for (int i = 0; i < 10; i++) {
        kari += load[i];
        if (kari >= ans) {
          printf("%d\\n", i + 1);
          break;
        }
      }
    }
  }
  return 0;
}
Problem p00034 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {
  int a, v1, v2, sum[10];
  char c;
  while (cin >> a >> c) {
    sum[0] = a;
    for (int i = 1; i < 10; i++) {
      cin >> a >> c;
      sum[i] = a + sum[i - 1];
    }
    cin >> v1 >> c >> v2;

    double t = ((double)v1 / (v1 + v2)) * sum[9];
    for (int i = 0; i < 10; i++) {
      if (t <= sum[i]) {
        cout << i + 1 << endl;
        break;
      }
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

int main() {
  int *a = new int[10];
  char c;
  while (true) {
    int dis = 0;
    for (int i = 0; i < 10; i++) {
      cin >> a[i] >> c;
      dis += a[i];
    }

    int v1, v2;
    cin >> v1 >> c >> v2;

    // cout << v1 << " " << v2 << " " << dis << endl;

    float vall = v1 + v2;
    float t = dis / vall;
    float res = ((float)v1) * t;
    int tmp = 0;
    int i;
    for (i = 0; i < 10; i++) {
      tmp += a[i];
      if (res <= tmp) {
        break;
      }
    }
    cout << i + 1 << endl;
  }
}
Problem p00034 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
#include <iostream>
using namespace std;

int main() {
  int l[10], v1, v2, sum;
  float x;
  while (scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", l, l + 1, l + 2, l + 3,
               l + 4, l + 5, l + 6, l + 7, l + 8, l + 9, &v1, &v2) +
         1) {
    for (int i = 1; i < 10; ++i) {
      l[i] += l[i - 1];
    }

    x = (float)l[9] * v1 / (v1 + v2);
    for (int i = 0; i < 10; ++i) {
      if (x <= l[i]) {
        cout << i + 1 << endl;
        break;
      }
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <cmath>
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
  int l[10], v1, v2;
  int len;
  float len1, len2;

  while (len = 0,
         scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", &l[0], &l[1], &l[2],
               &l[3], &l[4], &l[5], &l[6], &l[7], &l[8], &l[9], &v1, &v2) +
             1) {
    for (int i = 0; i < 10; ++i)
      len += l[i];

    len1 = 0;
    len2 = len;

    while (fabs(len1 - len2) > 0.1) {
      len1 += 0.01f * v1;
      len2 -= 0.01f * v2;
    }

    len2 = 0;
    for (int i = 0; i < 9; ++i) {
      if (len1 >= len2 && len1 < len2 + l[i]) {
        cout << i + 1 << endl;
        break;
      }
      len2 += l[i];
    }
  }

  return 0;
}
Problem p00034 (C++) — buggy submission, verdict: Time Limit Exceeded

#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#include <cstdio>

using namespace std;

int main() {
  int l[10], v[2];
  while (scanf("%d", &l[0]) != EOF) {
    vector<double> a;
    a.push_back(0);
    a.push_back(l[0]);
    for (int i = 1; i < 10; i++) {
      scanf(",%d", &l[i]);
      a.push_back(a.back() + l[i]);
    }
    scanf(",%d,%d", &v[0], &v[1]);
    double w = a.back() / (v[0] + v[1]);
    w *= v[0];
    for (int i = 1; i < a.size(); i++) {
      if (a[i] == w) {
        cout << i << endl;
        break;
      }
      if (a[i] > w && a[i - 1] < w) {
        cout << i << endl;
        break;
      }
    }
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define repp(i, r, n) for (int i = r; i < (int)n; i++)
using namespace std;
int in() {
  int x;
  cin >> x;
  return x;
}

int main() {
  int l[10];
  double v[2];
  while (scanf("%d", &l[0]) != EOF) {
    int m[99999] = {};
    m[0] = 1;
    for (int i = 1; i < 10; i++)
      scanf(",%d", &l[i]);
    char zzz, zzzz;
    cin >> zzz >> v[0] >> zzzz >> v[1];
    v[0] *= 0.1;
    v[1] *= 0.1;
    int now = 0;
    for (int i = 0; i < 10; i++) {
      m[l[i] + now + 1]++;
      now += l[i];
    }
    for (int i = 1; i < 99999; i++)
      m[i] += m[i - 1];
    int nn = 1;
    while (1) {
      nn += (int)v[0];
      now -= (int)v[1];
      if (nn > now) {
        cout << m[(nn + now) / 2] << endl;
        break;
      }
    }
  }

  return 0;
}
Problem p00034 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n)-1; i >= 0; i--)
#define ALL(a) (a).begin(), (a).end()
#define DUMP(o)                                                                \\
  { cerr << #o << " " << o << endl; }
#define DUMPC(o)                                                               \\
  {                                                                            \\
    cerr << #o;                                                                \\
    for (auto &e : (o))                                                        \\
      cerr << " " << e;                                                        \\
    cerr << endl;                                                              \\
  }
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

signed main() {
  while (true) {
    vector<int> l(10);
    int v1, v2;
    if (!(cin >> l[0]))
      break;
    char c;
    FOR(i, 1, 10) cin >> c >> l[i];
    cin >> c >> v1 >> c >> v2;
    int sum = accumulate(ALL(l), 0);
    double a = (double)sum * v1 / (v1 + v2);
    int temp = 0;
    FOR(i, 0, 10) {
      temp += l[i];
      if (temp >= a) {
        cout << i + 1 << endl;
        break;
      }
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#define _USE_MATH_DEFINES
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int main() {
  while (true) {
    char c;
    int l[11] = {}, v[2], L[11] = {};
    for (int i = 1; i <= 10; i++) {
      cin >> l[i] >> c;
      L[i] = L[i - 1] + l[i];
    }
    cin >> v[0] >> c >> v[1];

    double a = L[10] * (double)v[0] / (v[0] + v[1]);

    for (int i = 1; i <= 10; i++) {
      if (L[i] >= a) {
        cout << i << endl;
        break;
      }
    }
  }

  return 0;
}
Problem p00034 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;

int main() {
  int dis[10], v_0 = 0, v_1 = 0;
  while (scanf("%d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d", &dis[0],
               &dis[1], &dis[2], &dis[3], &dis[4], &dis[5], &dis[6], &dis[7],
               &dis[8], &dis[9], &v_0, &v_1) == 12) {
    int dsum = 0;
    double acum[10];
    for (int x = 0; x < 10; ++x) {
      dsum += dis[x];
      acum[x] = 1.0 * dsum;
    }
    double dd = v_0 * (dsum * 1.0 / (v_0 + v_1));
    // cout<<dd<<endl;
    int index = 0;
    while (index < 10 && acum[index] < dd) {
      ++index;
    }
    --index;
    if (acum[index] == dd)
      cout << index + 1 << endl;
    else
      cout << index + 2 << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;

int main() {
  int dis[10], v_0 = 0, v_1 = 0;
  while (scanf("%d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d", &dis[0],
               &dis[1], &dis[2], &dis[3], &dis[4], &dis[5], &dis[6], &dis[7],
               &dis[8], &dis[9], &v_0, &v_1)) {
    int dsum = 0;
    double acum[10];
    for (int x = 0; x < 10; ++x) {
      dsum += dis[x];
      acum[x] = 1.0 * dsum;
    }
    double dd = v_0 * (dsum * 1.0 / (v_0 + v_1));
    // cout<<dd<<endl;
    int index = 0;
    while (index < 10 && acum[index] < dd) {
      ++index;
    }
    --index;
    if (acum[index] == dd)
      cout << index + 1 << endl;
    else
      cout << index + 2 << endl;
  }
  return 0;
}
Problem p00034 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
#include <iostream>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;

int main() {
  double v1, v2;
  int l[10];
  while (~scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%lf,%lf", &l[0], &l[1], &l[2],
                &l[3], &l[4], &l[5], &l[6], &l[7], &l[8], &l[9], &v1, &v2)) {
    double sum = 0;
    rep(i, 10) { sum += l[i]; }
    double sum2 = 0;
    v1 = (v1 / (v1 + v2)) * sum;
    rep(i, 10) {
      sum2 += l[i];
      if (v1 <= sum2) {
        cout << i + 1 << endl;
        break;
      }
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <cstdio>
#include <iostream>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;

int main() {
  double v1, v2;
  int l[10];
  while (scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%lf,%lf", &l[0], &l[1], &l[2],
               &l[3], &l[4], &l[5], &l[6], &l[7], &l[8], &l[9], &v1, &v2)) {
    double sum = 0;
    rep(i, 10) { sum += l[i]; }
    double sum2 = 0;
    v1 = (v1 / (v1 + v2)) * sum;
    rep(i, 10) {
      sum2 += l[i];
      if (v1 < sum2) {
        cout << i << endl;
        break;
      }
    }
  }
  return 0;
}
Problem p00034 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cstdio>
#include <numeric>
using namespace std;
int main() {
  int l[10], v1, v2, ret;
  while (~scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", &l[0], &l[1], &l[2],
                &l[3], &l[4], &l[5], &l[6], &l[7], &l[8], &l[9], &v1, &v2)) {
    int sum = accumulate(l, l + 10, 0), k = 0;
    double ret = ((double)v1 / (v1 + v2)) * sum;
    for (int i = 0; i < 10; i++) {
      if ((k += l[i]) >= ret) {
        printf("%d\\n", i + 1);
        break;
      }
    }
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <numeric>
using namespace std;
int main() {
  int l[10], v1, v2, ret;
  while (scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", &l[0], &l[1], &l[2],
               &l[3], &l[4], &l[5], &l[6], &l[7], &l[8], &l[9], &v1, &v2)) {
    int sum = accumulate(l, l + 10, 0), k = 0;
    double ret = ((double)v1 / (v1 + v2)) * sum;
    for (int i = 0; i < 10; i++) {
      if ((k += l[i]) >= ret) {
        printf("%d\\n", i + 1);
        break;
      }
    }
  }
}