# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
717715 | 2023-04-02T11:17:32 Z | VMaksimoski008 | Garage (IOI09_garage) | C++14 | 2 ms | 340 KB |
#include <bits/stdc++.h> #define ll long long #define pb push_back using namespace std; void setIO() { ios_base::sync_with_stdio(false); cout.tie(0); cin.tie(0); } int main() { setIO(); int n, c, pos; int w, op; ll sum = 0; cin >> n >> c; set<int> free; map<int, int> par; queue<int> waitList; int rates[n+1]; int cars[c+1]; for(int i=0; i<n; i++) { cin >> rates[i+1]; free.insert(i+1); } for(int i=0; i<c; i++) { cin >> cars[i+1]; } for(int i=0; i<2*c; i++) { cin >> op; if(op > 0) { if(free.size() > 0) { int place = *free.begin(); sum += rates[place] * cars[op]; free.erase(free.begin()); par[op] = place; } else { waitList.push(op); } } else if(op < 0) { free.insert(par[abs(op)]); if(!waitList.empty()) { int car = waitList.front(); waitList.pop(); sum += rates[*free.begin()] * cars[car]; par[car] = *free.begin(); free.erase(*free.begin()); } par[abs(op)] = 0; } } cout << sum << '\n'; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 340 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 1 ms | 340 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 2 ms | 340 KB | Output is correct |
19 | Correct | 2 ms | 340 KB | Output is correct |
20 | Correct | 2 ms | 340 KB | Output is correct |