답안 #431111

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
431111 2021-06-17T09:41:44 Z SAAD Garage (IOI09_garage) C++17
20 / 100
5 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;
	ll 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:38:6: warning: unused variable 'c' [-Wunused-variable]
   38 |  int c = 0 , p ;
      |      ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 0 ms 204 KB Output isn't correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Incorrect 1 ms 204 KB Output isn't correct
7 Incorrect 0 ms 204 KB Output isn't correct
8 Incorrect 0 ms 204 KB Output isn't correct
9 Incorrect 1 ms 204 KB Output isn't correct
10 Incorrect 1 ms 204 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 204 KB Output isn't correct
14 Incorrect 1 ms 204 KB Output isn't correct
15 Incorrect 3 ms 204 KB Output isn't correct
16 Incorrect 2 ms 204 KB Output isn't correct
17 Incorrect 2 ms 204 KB Output isn't correct
18 Incorrect 3 ms 204 KB Output isn't correct
19 Incorrect 5 ms 332 KB Output isn't correct
20 Incorrect 3 ms 204 KB Output isn't correct