Submission #999285

# Submission time Handle Problem Language Result Execution time Memory
999285 2024-06-15T09:05:08 Z SonicML Garage (IOI09_garage) C++14
40 / 100
1 ms 604 KB
#include <iostream>
#include <queue>

using namespace std;

int n, m;

int const NMAX = 100;
int arr[1 + NMAX];
int taken[1 + NMAX];

int const MMAX = 2000;
int weight[1 + MMAX];
int pos[1 + MMAX];

queue <int> q;

int main() {
        
  cin >> n >> m;
  for(int i = 1;i <= n;i++) {
    cin >> arr[i];
  } 
  for(int i = 1;i <= m;i++) {
    cin >> weight[i];
  } 
  int canPark = n, ans = 0;
  for(int t = 1;t <= 2 * m;t++) {
    int c;
    cin >> c;
    if(c > 0) {
      if(canPark == 0) {
        q.push(c);
      }else {
        bool foundSpot = false;
        for(int i = 1;i <= n && !foundSpot;i++) {
          if(taken[i] == false) {
            ans += arr[i] * weight[c];
            taken[i] = true;
            foundSpot = true;
            canPark--;
            pos[c] = i;
          } 
        } 
      } 
    } else {
      c = -c;
      if(canPark == 0) {
       if(!q.empty()) {
          ans += arr[pos[c]] * weight[q.front()];
          q.pop();
        }else{
          taken[pos[c]] = false;
          canPark++;
        }
      } else {
        taken[pos[c]] = false;
        canPark++;
      }
    }
  }
  cout << ans << '\n';
  return 0;
}

# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 440 KB Output isn't correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 1 ms 344 KB Output isn't correct
5 Correct 0 ms 348 KB Output is correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Correct 0 ms 348 KB Output is correct
8 Incorrect 1 ms 604 KB Output isn't correct
9 Correct 0 ms 348 KB Output is correct
10 Incorrect 0 ms 344 KB Output isn't correct
11 Correct 0 ms 348 KB Output is correct
12 Incorrect 0 ms 348 KB Output isn't correct
13 Correct 1 ms 348 KB Output is correct
14 Incorrect 0 ms 348 KB Output isn't correct
15 Correct 1 ms 348 KB Output is correct
16 Incorrect 1 ms 600 KB Output isn't correct
17 Incorrect 1 ms 348 KB Output isn't correct
18 Incorrect 1 ms 348 KB Output isn't correct
19 Incorrect 1 ms 348 KB Output isn't correct
20 Incorrect 1 ms 476 KB Output isn't correct