Блог пользователя dummyactforaskingdoubts

Автор dummyactforaskingdoubts, история, 7 часов назад, По-английски

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? SlavicG

Полный текст и комментарии »

  • Проголосовать: нравится
  • +2
  • Проголосовать: не нравится