I am making an exercise (https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=&problem=2899&mosmsg=Submission+received+with+ID+22762175) on UVa online judge. My code works fine on my computer, but when I submit my code, it reports me a Runtime error. What am I doing wrong? Here is my code:
#include <iostream>
using namespace std;
int t;
int n = 50;
int speed;
int main(int argc, char ** argv) {
std::cin >> t;
int data[t][n] = {0};
for (int i = 0; i < t; i++) {
std::cin >> n;
data[i][0] = n;
for (int j = 1; j <= n; j++) {
std::cin >> data[i][j];
}
}
for (int i = 0; i < t; i++) {
speed = 0;
for (int j = 1; j <= data[i][0]; j++) {
if (data[i][j] > speed) {
speed = data[i][j];
}
}
std::cout << "Case " << i+1 << ": " << speed << endl;
}
return 0;
}
Thank you in advance.