烧电源 。。略水。。
竟然WA了一次- -
http://poj.org/problem?id=1484
给出一堆用电器的信息,然后操作哪个哪个,问超没超限- -
#include <cstdio>
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <fstream>
#define INF 0x3f3f3f3f
using namespace std;
int n,m,c;
int a[22];
int vis[22];
int main()
{
//ifstream cin("input.txt");
int kase=0;
while(cin>>n>>m>>c,n)
{
kase++;
int sum=0;
int max=-1;
bool blown=false;
memset(vis,0,sizeof(vis));
for (int i = 1; i <= n; ++i)
{
cin>>a[i];
}
for (int i = 1; i <= m; ++i)
{
int op;
cin>>op;
if(vis[op]==0) sum+=a[op],vis[op]=1;
else sum-=a[op],vis[op]=0;
if(sum>c) blown = true;
if(max<sum) max=sum;
}
if(blown) printf("Sequence %d\nFuse was blown.\n\n",kase );
else printf("Sequence %d\nFuse was not blown.\nMaximal power consumption was %d amperes.\n\n",kase,max );
}
return 0;
}