Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- #define endl '\n'
- #define sz(x) int(x.size())
- #define all(x) x.begin(), x.end()
- int main() {
- ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
- int n, m, c;
- int test = 0;
- char report[2][100] = {
- "Fuse was blown.",
- "Fuse was not blown.\nMaximal power consumption was "
- };
- while (scanf("%d %d %d", &n, &m, &c), n || m || c) {
- printf("Sequence %d\n", ++test);
- bool is_fuse_safe = true;
- bool is_device_turned[n + 1]{};
- int consumption[n + 1];
- int amperes = 0;
- int Maxial_power_consumption = 0;
- for (int i = 1; i <= n; i++) {
- scanf("%d", &consumption[i]);
- }
- int switch_device;
- while (m--) {
- scanf("%d", &switch_device);
- is_device_turned[switch_device] ^= 1;
- amperes += (is_device_turned[switch_device] ? 1 : -1) * consumption[switch_device];
- Maxial_power_consumption = max(Maxial_power_consumption, amperes);
- is_fuse_safe &= (amperes <= c);
- }
- printf("%s", report[is_fuse_safe]);
- if (is_fuse_safe) printf("%d amperes.", Maxial_power_consumption);
- printf("\n\n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement