Submission #431107

# Submission time Handle Problem Language Result Execution time Memory
431107 2021-06-17T09:39:25 Z SAAD Garage (IOI09_garage) C++17
20 / 100
3 ms 332 KB
#define F first
#define S second
#define rep(i,a,b) for(int i=a;!(a==b&&i!=b)&&((i<=b&&b>=a)||(i>=b&&a>=b));i+=(a<=b?1:-1))
#define pb push_back
#define Fbitl __builtin_ffs
#define bit1 __builtin_popcount
//#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string.h>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<vl> vvl;
int arr[(int)1e5] , car[(int)1e5] , pos[(int)1e5];
bool visa[1002];
int main() {
	int n, m , ans = 0;
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
		visa[arr[i]] = true;
	}
	queue <int> q;
	int c = 0 , p ;
	for (int i = 1; i <= m; i++) {
		cin >> car[i];
	}
	for (int j = 0; j < m*2; j++) {
		cin >> p;
		if (p < 0) {
			p = -p;
			visa[pos[p]] = true;
			if (q.size()) {
				pos[q.front()] = pos[p];
				visa[pos[p]] = false;
				ans += pos[p] * car[q.front()];
				q.pop();
			}
		}
		else {
			if (q.size()) q.push(p);
			else
			for (int i = 0; i <= 100;i++) {
				if ( visa[arr[i]] ) {
					visa[arr[i]] = false;
					pos[p] = arr[i];
					ans += arr[i] * car[p];
					break;
				}
				if (i == 100) q.push(p);
			}
		}
	}
	cout << ans;
	return 0;
}

Compilation message

garage.cpp: In function 'int main()':
garage.cpp:37:6: warning: unused variable 'c' [-Wunused-variable]
   37 |  int c = 0 , p ;
      |      ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Incorrect 1 ms 204 KB Output isn't correct
7 Incorrect 1 ms 204 KB Output isn't correct
8 Incorrect 1 ms 204 KB Output isn't correct
9 Incorrect 1 ms 204 KB Output isn't correct
10 Incorrect 1 ms 304 KB Output isn't correct
11 Incorrect 1 ms 204 KB Output isn't correct
12 Incorrect 1 ms 204 KB Output isn't correct
13 Incorrect 1 ms 312 KB Output isn't correct
14 Incorrect 1 ms 332 KB Output isn't correct
15 Incorrect 2 ms 204 KB Output isn't correct
16 Incorrect 2 ms 332 KB Output isn't correct
17 Incorrect 3 ms 332 KB Output isn't correct
18 Incorrect 3 ms 332 KB Output isn't correct
19 Incorrect 3 ms 332 KB Output isn't correct
20 Incorrect 3 ms 332 KB Output isn't correct