Having an Issue with C++ (Beginner)

Revision en5, by Gwazy, 2020-07-12 02:47:25

29A - Плевая задача

#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
using namespace std;
 
int main() {
    IOS
 
    int n;
    cin >> n;
    int x[n], d[n];
    x[0] = 0;
    d[0] = 0;
 
    for(int i = 0; i < n; i++){ 
        scanf("%d", &x[i]);
        scanf("%d", &d[i]);
    }
    
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            if ((x[i] + d[i]) == x[j]) {
                if(x[j] + d[j] == x[i]) {
                    cout << "YES";
                    return 0;
                }
            }
        }
    }
    cout << "NO";
    return 0; 
}

Hey Code Forcers, I'm running this code on my terminal, and I'm getting a correct output for all tests.

However, when I submit the code to CodeForces, I fail test case two.

Initially, I was getting an uninitialized value usage before I initialised arrays x and d, could it be related?

I would appreciate any help,

Thanks

Tags 29a, c++, #newbie

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en5 English Gwazy 2020-07-12 02:47:25 1 Tiny change: 'alue usage, before I ' -> 'alue usage before I '
en4 English Gwazy 2020-07-12 02:36:29 57
en3 English Gwazy 2020-07-12 02:35:05 0 (published)
en2 English Gwazy 2020-07-12 02:34:38 46 (saved to drafts)
en1 English Gwazy 2020-07-12 02:34:04 1031 Initial revision (published)