# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
973027 | Frigglet | Garage (IOI09_garage) | C++14 | 2 ms | 604 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.
#include <algorithm>
#include <iostream>
#include <vector>
#include <numeric>
#include <utility>
#include <set>
#include <unordered_map>
#include <cmath>
#include <string.h>
#include <cctype>
#include <string>
using namespace std;
using ll = long long;
int main(){
ll n, m;
cin >> n >> m;
ll rs, wk;
ll a;
vector<ll> rates;
vector<ll> weights;
vector<ll> occupied;
unordered_map<ll,ll> spacemem;
for(int i=0; i<n; i++){
occupied.push_back(0);
}
ll totalsum=0;
ll counter=0;
bool occupation=false;
for(int i=0; i<n; i++){
cin >> rs;
rates.push_back(rs);
}
for(int i=0; i<m; i++){
cin >> wk;
weights.push_back(wk);
}
for(int i=0; i<m*2; i++){
cin >> a;
occupation = false;
counter = 0;
if(a>0){
while(occupation==false){
if(occupied[counter]==0){
occupation = true;
occupied[counter]=1;
spacemem[a-1]=counter;
}
else{
counter++;
}
}
totalsum += rates[counter]*weights[a-1];
}
else{
occupied[spacemem[abs(a)-1]]=0;
}
}
cout << totalsum;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |