# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
431107 | SAAD | Garage (IOI09_garage) | C++17 | 3 ms | 332 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#define F first
#define S second
#define rep(i,a,b) for(int i=a;!(a==b&&i!=b)&&((i<=b&&b>=a)||(i>=b&&a>=b));i+=(a<=b?1:-1))
#define pb push_back
#define Fbitl __builtin_ffs
#define bit1 __builtin_popcount
//#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string.h>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<vl> vvl;
int arr[(int)1e5] , car[(int)1e5] , pos[(int)1e5];
bool visa[1002];
int main() {
int n, m , ans = 0;
cin >> n >> m;
for (int i = 0; i < n; i++) {
cin >> arr[i];
visa[arr[i]] = true;
}
queue <int> q;
int c = 0 , p ;
for (int i = 1; i <= m; i++) {
cin >> car[i];
}
for (int j = 0; j < m*2; j++) {
cin >> p;
if (p < 0) {
p = -p;
visa[pos[p]] = true;
if (q.size()) {
pos[q.front()] = pos[p];
visa[pos[p]] = false;
ans += pos[p] * car[q.front()];
q.pop();
}
}
else {
if (q.size()) q.push(p);
else
for (int i = 0; i <= 100;i++) {
if ( visa[arr[i]] ) {
visa[arr[i]] = false;
pos[p] = arr[i];
ans += arr[i] * car[p];
break;
}
if (i == 100) q.push(p);
}
}
}
cout << ans;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |