Submission #225960

# Submission time Handle Problem Language Result Execution time Memory
225960 2020-04-22T06:07:33 Z FieryPhoenix Garage (IOI09_garage) C++11
45 / 100
13 ms 512 KB
#include <bits/stdc++.h>
using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
#define INF 2001001001
#define MOD 1000000007

int N,M;
int R[101];
ll ans;
int occ[101];
int W[101];

int main()
{
  //ios_base::sync_with_stdio(0);cin.tie(0);
  //freopen (".in","r",stdin);
  //freopen (".out","w",stdout);
  cin>>N>>M;
  for (int i=1;i<=N;i++)
    cin>>R[i];
  for (int i=1;i<=M;i++)
    cin>>W[i];
  queue<int>q;
  for (int i=1;i<=M*2;i++){
    int X; cin>>X;
    if (X>0)
      q.push(X);
    else{
      for (int j=1;j<=N;j++)
	if (occ[j]==-X){
	  occ[j]=0;
	  break;
	}
    }
    while (!q.empty()){
      int spot=-1;
      for (int j=1;j<=N;j++)
	if (occ[j]==0){
	  spot=j;
	  break;
	}
      if (spot==-1) break;
      occ[spot]=q.front();
      ans+=W[q.front()]*R[spot];
      q.pop();
    }
  }
  cout<<ans<<endl;
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 256 KB Output is correct
10 Incorrect 5 ms 256 KB Output isn't correct
11 Incorrect 5 ms 384 KB Output isn't correct
12 Incorrect 5 ms 384 KB Output isn't correct
13 Incorrect 13 ms 384 KB Output isn't correct
14 Incorrect 5 ms 384 KB Output isn't correct
15 Runtime error 6 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 6 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 6 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 6 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Runtime error 6 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
20 Runtime error 6 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)