Submission #53447

# Submission time Handle Problem Language Result Execution time Memory
53447 2018-06-30T04:42:01 Z 강태규(#1417) Garage (IOI09_garage) C++11
100 / 100
4 ms 768 KB
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;

int n, m;
int r[101];
int w[2001];
int p[2001];
priority_queue<int> seat;
queue<int> car;
int main() {
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", r + i);
        seat.push(-i);
    }
    for (int i = 1; i <= m; ++i) {
        scanf("%d", w + i);
    }
    llong ans = 0;
    for (int i = 0; i < (m << 1); ++i) {
        int x;
        scanf("%d", &x);
        if (x < 0) {
            x = -x;
            seat.push(p[x]);
        }
        else {
            car.push(x);
        }
        while (!car.empty() && !seat.empty()) {
            p[car.front()] = seat.top();
            ans += r[-seat.top()] * w[car.front()];
            car.pop();
            seat.pop();
        }
    }
    printf("%lld\n", ans);
	return 0;
}

Compilation message

garage.cpp: In function 'int main()':
garage.cpp:28:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &n, &m);
     ~~~~~^~~~~~~~~~~~~~~~
garage.cpp:30:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", r + i);
         ~~~~~^~~~~~~~~~~~~
garage.cpp:34:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", w + i);
         ~~~~~^~~~~~~~~~~~~
garage.cpp:39:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &x);
         ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 2 ms 516 KB Output is correct
4 Correct 2 ms 516 KB Output is correct
5 Correct 2 ms 516 KB Output is correct
6 Correct 2 ms 516 KB Output is correct
7 Correct 2 ms 516 KB Output is correct
8 Correct 3 ms 516 KB Output is correct
9 Correct 2 ms 516 KB Output is correct
10 Correct 3 ms 516 KB Output is correct
11 Correct 2 ms 608 KB Output is correct
12 Correct 3 ms 608 KB Output is correct
13 Correct 3 ms 608 KB Output is correct
14 Correct 3 ms 608 KB Output is correct
15 Correct 3 ms 608 KB Output is correct
16 Correct 2 ms 608 KB Output is correct
17 Correct 3 ms 768 KB Output is correct
18 Correct 3 ms 768 KB Output is correct
19 Correct 3 ms 768 KB Output is correct
20 Correct 4 ms 768 KB Output is correct