#include <bits/stdc++.h>
#define pb push_back
#define jizz ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define ET cout << "\n"
#define F first
#define S second
#define MP make_pair
#define ALL(v) v.begin(),v.end()
#define MEM memset(i,j,sizeof i)
#define DB(a,s,e) {for(int i=s;i<e;++i) cout << a[i] << " ";ET;}
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int price[105],wei[2005],pl[2005];
bitset<105> used;
queue<int> q;
int main()
{jizz
int n,m,x,ans=0;
cin >> n >> m;
for(int i=1;i<=n;++i)
cin >> price[i];
for(int i=1;i<=m;++i)
cin >> wei[i];
for(int i=1;i<=2*m;++i)
{
cin >> x;
if(x<0)
{
used[pl[-x]]=0;
if(!q.empty())
pl[q.front()]=pl[-x],ans+=wei[q.front()]*price[pl[-x]],q.pop(),used[pl[-x]]=1;
}
else
if(used.count()==n) q.push(x);
else
{
for(int j=1;j<=n;++j)
if(!used[j])
{
pl[x]=j,ans+=wei[x]*price[j],used[j]=1;
break;
}
}
}
cout << ans << "\n";
}
Compilation message
garage.cpp: In function 'int main()':
garage.cpp:38:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(used.count()==n) q.push(x);
~~~~~~~~~~~~^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
3 ms |
420 KB |
Output is correct |
18 |
Correct |
3 ms |
376 KB |
Output is correct |
19 |
Correct |
3 ms |
376 KB |
Output is correct |
20 |
Correct |
3 ms |
376 KB |
Output is correct |