#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;
int main(){
int n, m, c, m_lines, ans, mx, fuse, cs = 1;
while(cin >> n >> m >> c){
if(m == 0 && m == n && m == c)break;
int n_lines[n+1], toggle[n+1];
memset(toggle, 0, sizeof(toggle));
for(int i = 1; i <= n; i++)cin >> n_lines[i];
ans = 0;int cnt = 0;fuse = 0, mx = 0;
while(cin >> m_lines){
cnt++;
if(toggle[m_lines] == 0)ans += n_lines[m_lines], toggle[m_lines] = 1;
else ans -= n_lines[m_lines], toggle[m_lines] = 0;
if(ans <= c){
if(mx < ans)mx = ans;
}
else fuse = 1;
if(cnt == m)break;
}
cout << "Sequence " << cs << endl;
if(!fuse)cout << "Fuse was not blown." << "\n" << "Maximal power consumption was " << mx << " amperes." << endl;
else cout << "Fuse was blown." << endl;cs++;
cout << endl;
}
return 0;
}
#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;
int main(){
int n, m, c, m_lines, ans, mx, fuse, cs = 1;
while(cin >> n >> m >> c){
if(m == 0 && m == n && m == c)break;
int n_lines[n+1], toggle[n+1];
memset(toggle, 0, sizeof(toggle));
for(int i = 1; i <= n; i++)cin >> n_lines[i];
ans = 0;int cnt = 0;fuse = 0, mx = 0;
while(cin >> m_lines){
cnt++;
if(toggle[m_lines] == 0)ans += n_lines[m_lines], toggle[m_lines] = 1;
else ans -= n_lines[m_lines], toggle[m_lines] = 0;
if(ans <= c){
if(mx < ans)mx = ans;
}
else fuse = 1;
if(cnt == m)break;
}
cout << "Sequence " << cs << endl;
if(!fuse)cout << "Fuse was not blown." << "\n" << "Maximal power consumption was " << mx << " amperes." << endl;
else cout << "Fuse was blown." << endl;cs++;
cout << endl;
}
return 0;
}
No comments:
Post a Comment