Having an Issue with C++ (Beginner)
Difference between en3 and en4, changed 57 character(s)
[problem: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 ↵

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)