Submission #54514

#TimeUsernameProblemLanguageResultExecution timeMemory
54514updown1Garage (IOI09_garage)C++17
100 / 100
3 ms832 KiB
#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)

garage.cpp:22:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
#Verdict Execution timeMemoryGrader output
Fetching results...