View Code of Problem 128

#include<iostream>
using namespace std;
int main(){
	int n,m;
	while(cin>>n>>m){
		int a[m],b[m],t[m];
		for(int i=0;i<m;i++){
			cin>>a[i]>>b[i]>>t[i];
		}
		int temp;
		for(int i=0;i<m;i++){
			if(b[i]==n){
				temp=i;
				break;
			}
		}
		int time=0;
		for(int i=0;i<=temp;i++){
			time=time+t[i];
		}
		if(time<0)cout<<"YES"<<'\n';
		else cout<<"NO"<<'\n';
	}
} 

Double click to view unformatted code.


Back to problem 128