Algorithm
Code Examples
#1 Code Example with C++ Programming
Code -
                                                        C++ Programming
#include <bits/stdc++.h>
using namespace std;
int n, k, f, t;
int main() {
  scanf("%d %d", &n, &k);
  int res = -2e9;
  while(n-- != 0) {
    scanf("%d %d", &f, &t);
    if(t > k)
      res = max(res, f - (t - k));
    else
      res = max(res, f);
  }
  if(res == -2e9)
    puts("-1");
  else
    printf("%d\n", res);
  
  return 0;
}Input
                                                            2 5
3 3
4 5
                                                    3 3
4 5
Output
                                                            4
                                                                                                                    
                                                    Demonstration
Codeforces Solution-Lunch Rush-Solution in C, C++, Java, Python
