Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
802 B
4
Indexable
#include<stdio.h>
void solve(){
    int b,n;
    while(scanf("%d %d\n",&b,&n)!=EOF){
        if(b==0&&n==0){
            break;
        }else{
            int taka[100000];
            for(int i=1;i<=b;i++){
                scanf("%d",&taka[i]);
            }
            scanf("\n");
            while(n--){
                int p,q,r;
                scanf("%d %d %d\n",&p,&q,&r);
                taka[p]-=r;
                taka[q]+=r;
            }
            int chk=0;
            for(int i=1;i<=b;i++){
                if(taka[b]<0){
                    chk=1;
                    break;
                }
            }
            if(chk){
                printf("N\n");
            }else{
                printf("S\n");
            }
        }
    }
}
int main()
{
    solve();
    return 0;
}