You are viewing a single comment's thread. Return to all comments →
Simple solution:
#include <iostream> using namespace std; int main() { int n; cin>>n; int a[n],b[n]; for(int i=0;i<n;i++){ cin>>a[i]>>b[i]; } int sum = 0,state = 0; for(int i=0;i<n;i++){ if(sum<0){ state = i; sum=0; } sum = sum + a[i] - b[i]; } cout<<state; return 0; }
Seems like cookies are disabled on this browser, please enable them to open this website
Truck Tour
You are viewing a single comment's thread. Return to all comments →
Simple solution: