# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
54514 | updown1 | Garage (IOI09_garage) | C++17 | 3 ms | 832 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 <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i, a, b) for(int i=a; i<b; i++)
#define ffi For(i, 0, N)
#define ffj For(j, 0, M)
#define ffa ffi ffj
#define s <<" "<<
#define w cout
#define e "\n"
#define pb push_back
#define mp make_pair
#define a first
#define b second
#define int ll
const int MAXN=100, MAXM=2000, INF=1000000000000000000;
///500,000,000
int N, M, R[MAXN], W[MAXM], spot[MAXM], out;
priority_queue<int> open;
queue<int> next1;
main() {
//ifstream cin("test.in");
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> N >> M;
ffi cin >> R[i];
ffj cin >> W[j];
ffi open.push(-i);
For (j, 0, 2*M) {
int act; cin >> act;
if (act < 0) {
act *= -1;
act--;
open.push(-spot[act]);
if (!next1.empty()) {
int act = next1.front();
next1.pop();
int take = -open.top();
open.pop();
out += W[act]*R[take];
spot[act] = take;
}
}
else {
act--;
if (!open.empty()) {
int take = -open.top();
open.pop();
out += W[act]*R[take];
spot[act] = take;
}
else next1.push(act);
}
}
w<< out<<e;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |