# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
445038 | 2021-07-16T09:55:56 Z | cpp219 | Garage (IOI09_garage) | C++14 | 1 ms | 456 KB |
#pragma GCC optimization O2 #pragma GCC optimization "unroll-loop" #pragma target ("avx2") #include <bits/stdc++.h> #define ll int #define ld long double #define fs first #define sc second using namespace std; typedef pair<ll,ll> LL; const ll N = 2000 + 9; const ll Log2 = 30; const ll mod = 1e9 + 7; priority_queue<ll,vector<ll>,greater<ll>> spare; queue<ll> wait; ll n,m,R[N],a[N],x,take[N]; int main(){ ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0); #define task "tst" if (fopen(task".INP","r")){ freopen(task".INP","r",stdin); //freopen(task".OUT","w",stdout); } ll ans = 0; cin>>n>>m; for (ll i = 1;i <= n;i++) cin>>R[i],spare.push(i); for (ll i = 1;i <= m;i++) cin>>a[i]; for (ll i = 1;i <= 2*m;i++){ cin>>x; if (x > 0){ if (!spare.empty()){ ll now = spare.top(); spare.pop(); take[x] = now; ans += R[now] * a[x]; } else wait.push(x); } else{ x = -x; ll now = take[x]; spare.push(now); while (!wait.empty() && !spare.empty()){ ll place = spare.top(); spare.pop(); ll car = wait.front(); wait.pop(); ans += R[place] * a[car]; } } } cout<<ans; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Incorrect | 0 ms | 316 KB | Output isn't correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Incorrect | 1 ms | 204 KB | Output isn't correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Incorrect | 1 ms | 204 KB | Output isn't correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Incorrect | 1 ms | 204 KB | Output isn't correct |
9 | Correct | 1 ms | 204 KB | Output is correct |
10 | Incorrect | 1 ms | 204 KB | Output isn't correct |
11 | Correct | 1 ms | 204 KB | Output is correct |
12 | Incorrect | 1 ms | 204 KB | Output isn't correct |
13 | Correct | 1 ms | 332 KB | Output is correct |
14 | Incorrect | 1 ms | 332 KB | Output isn't correct |
15 | Correct | 1 ms | 328 KB | Output is correct |
16 | Incorrect | 1 ms | 332 KB | Output isn't correct |
17 | Incorrect | 1 ms | 332 KB | Output isn't correct |
18 | Incorrect | 1 ms | 456 KB | Output isn't correct |
19 | Incorrect | 1 ms | 332 KB | Output isn't correct |
20 | Incorrect | 1 ms | 332 KB | Output isn't correct |