Why other online ides are different from codeforces online ide?
Difference between en2 and en3, changed 22 character(s)

This is my code for problem C of Codeforces Round 964 (Div. 4), it was a pretty straightforward but i was going out of bounds↵

and ended up submitting wrong code twice, The interesting part is not even my sublime and codechef ides were able to detect it,↵
below is my implementation and how the codeforces and other ides give different outputs↵


~~~~~↵
#include <bits/stdc++.h>↵
#define int long long↵
#define endl "\n"↵
using namespace std;↵

void solve(){↵
    int n,s,m; ↵
    cin>>n>>s>>m;↵
    vector<pair<int,int>>v;↵
    v.push_back({0,0});↵
    for(int i=0;i<n;++i){↵
        int l, r; cin>>l>>r;↵
        v.push_back({l,r});↵
    }↵
    v.push_back({m,m});↵
    sort(v.begin(),v.end());↵
    for(int i=0;i<=n+1;++i){↵
        if(v[i+1].first-v[i].second>=s){↵
            cout<<v[i+1].first<<endl;↵
            cout<<"YES"<<endl;↵
            return;↵
        }↵
    }↵
    cout<<"NO"<<endl;↵
}↵

signed main(){↵
ios_base::sync_with_stdio(false);↵
    cin.tie(NULL); cout.tie(NULL);↵
int t; cin>>t;↵
while(t--) solve();↵
return 0;↵
}↵
~~~~~↵



it will give output on codeforces ide as ↵

2053669231248↵
YES↵

on test case↵

1↵
3 3 10↵
1 2↵
3 5↵
6 8↵
 ↵
and same code is giving output as ↵

NO↵
on other online ides and sublime↵

why this strange anamoly can anyone explain?↵
[user:SlavicG,2024-08-06]↵

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English dummyactforaskingdoubts 2024-08-06 23:06:16 22
en2 English dummyactforaskingdoubts 2024-08-06 23:05:15 0 Tiny change: 'This is my' -> '\n~~~~~\nYour code here...\n~~~~~\n\nThis is my'
en1 English dummyactforaskingdoubts 2024-08-06 23:03:53 1374 Initial revision (published)