ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1196. History Exam

Why Runtime error (stack overflow) C++ help pls!!
Posted by Aldar1232 2 Jan 2014 20:37
#include <iostream>
using namespace std;

int main()
{
    int N, M;  int S[15001];
 int S1[1000001];

    cin >> N;
    for (int i1 = 1; i1 <= N; i1++)
        cin >> S[i1];


    int f = 0;

    cin >> M;
    for (int i = 1; i <= M; i++)
        cin >> S1[i];

    for (int i1 = 1; i1 <= N; i1++)
    for (int i = 1; i <= M; i++)
    if (S[i1] == S1[i]) f++;

    cout << f;
}

Re: Why Runtime error (stack overflow) C++ help pls!!
Posted by Anton Malyuta 2 Jan 2014 22:01
S[15001] <--> S[0..15000]
S1[1000001] <--> S1[0..1000000]