Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main()
- {
- int n,m,c,cnt=0;
- while(1){
- cnt++;
- scanf("%d %d %d",&n,&m,&c);
- if(n==0 && m==0 && c==0)
- break;
- int i,a[100],flag[100];
- for(i=1;i<=n;i++){
- scanf("%d",&a[i]);
- flag[i]=0;
- }
- int j,total=0,max=0;
- for(i=1;i<=m;i++){
- scanf("%d",&j);
- if(flag[j]==0){
- total=total+a[j];
- flag[j]=1;
- }
- else{
- total=total-a[j];
- flag[j]=0;
- }
- if(max<total)
- max=total;
- }
- printf("Sequence %d\n",cnt);
- if(total>c)
- printf("Fuse was blown.\n\n");
- else
- printf("Fuse was not blown.\nMaximal power consumption was %d amperes.\n\n",max);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement