Advertisement
erfanul007

UVa 661

Nov 24th, 2018
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4. int n,m,c,cnt=0;
  5. while(1){
  6. cnt++;
  7. scanf("%d %d %d",&n,&m,&c);
  8. if(n==0 && m==0 && c==0)
  9. break;
  10. int i,a[100],flag[100];
  11. for(i=1;i<=n;i++){
  12. scanf("%d",&a[i]);
  13. flag[i]=0;
  14. }
  15. int j,total=0,max=0;
  16. for(i=1;i<=m;i++){
  17. scanf("%d",&j);
  18. if(flag[j]==0){
  19. total=total+a[j];
  20. flag[j]=1;
  21. }
  22. else{
  23. total=total-a[j];
  24. flag[j]=0;
  25. }
  26. if(max<total)
  27. max=total;
  28. }
  29. printf("Sequence %d\n",cnt);
  30. if(total>c)
  31. printf("Fuse was blown.\n\n");
  32. else
  33. printf("Fuse was not blown.\nMaximal power consumption was %d amperes.\n\n",max);
  34. }
  35. return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement