fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define GG ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  4. int main () { GG;
  5. int n,c=0,mx=0,a,b; cin>>n;
  6. for(int i=0;i<n;i++)
  7. { cin>>a>>b;
  8. c+=-a+b;
  9. mx=max(mx,c);
  10. }
  11. cout<<mx<<"\n";
  12. return 0;}
Success #stdin #stdout 0.01s 5304KB
stdin
4
0 3
2 5
4 5
4 0
stdout
7