# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
558766 |
2022-05-08T09:52:10 Z |
karon |
Garage (IOI09_garage) |
C++14 |
|
5 ms |
372 KB |
#include <bits/stdc++.h>
// #include "laugh.h"
#define pb push_back
#define rs resize
#define debug printf("Hello\n")
#define Pi 3.141592653589793
#define sz(a) ll((a).size())
#define all(x) (x).begin(), (x).end()
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl "\n"
#define mp make_pair
#define f first
#define s second
#define vt vector
#define rst(a,b) memset((a),(b), sizeof(a))
#define FOR(a, b, c) for (ll a = (b); (a) < (c); ++(a))
#define FORE(a, b, c) for (ll a = (b); (a) <= (c); ++(a))
#define FORR(a, b, c) for (ll a = (b); (a) >= (c); --(a))
#define umap unordered_map
#define len(a) (a).length()
#define pqueue priority_queue
using namespace std;
using vi = vector<int>;
using ui = unsigned int;
using ll = long long;
using pll = pair<ll,ll>;
using vll = vector<ll>;
using ull = unsigned long long;
using pii = pair<int, int>;
bool cmp(const vt<int> &a, const vt<int> &b){
if(a[0] != b[0])return a[0]>b[0];
if(a[1] != b[1])return a[1]>b[1];
return a[2] < b[2];
}
int parent[2001];
int find(int x){
if(parent[x] == -1)return x;
return find(parent[x]);
}
void solve(){
int n,m;cin >> n >> m;
int rate[101], w[2001], imap[2001];
rst(parent,-1);
FOR(i,1,n+1)cin >> rate[i];
FOR(i,1,m+1)cin >> w[i];
ll ans = 0;
FOR(i,0,2*m){
int q;cin >> q;
if(q>0){
int tmp = find(1);
ans += w[q]*rate[tmp];
parent[tmp] = tmp + 1;
imap[q] = tmp;
}else{
q = -q;
parent[imap[q]] = -1;
}
}
cout << ans << endl;
}
int main(){
fastio;
solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
3 |
Correct |
1 ms |
228 KB |
Output is correct |
4 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
15 |
Correct |
1 ms |
352 KB |
Output is correct |
16 |
Incorrect |
1 ms |
352 KB |
Output isn't correct |
17 |
Incorrect |
1 ms |
352 KB |
Output isn't correct |
18 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
19 |
Incorrect |
5 ms |
372 KB |
Output isn't correct |
20 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |