Submission #1110988

# Submission time Handle Problem Language Result Execution time Memory
1110988 2024-11-11T08:51:04 Z Zflop Garage (IOI09_garage) C++14
100 / 100
1 ms 592 KB
#include <bits/stdc++.h>
using namespace std;
const int NMAX = 101;
int N,M,ans,A[NMAX],aloc[2001],W[2001];
main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	set<int>m;
	cin >> N >> M;
	for (int i = 1; i <= N;++i) m.insert(i);
	for (int i = 1; i <= N;++i)
        cin >> A[i];
    for (int i = 1; i <= M;++i)
        cin >> W[i];
    queue<int>q;
    for (int i = 1; i <= 2 * M;++i) {
        int x; cin >> x;
        if (x > 0) {
            q.push(x);
        } else {
            m.insert(aloc[-x]);
        }
        while (m.size() && q.size()) {
            auto a = *m.begin();
            auto b = q.front();
            q.pop();
            m.erase(a);
            aloc[b] = a;
            ans += A[a] * W[b];
        }
    }
    cout << ans;
}

Compilation message

garage.cpp:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    5 | main(){
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 504 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 592 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 592 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 504 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 488 KB Output is correct
19 Correct 1 ms 504 KB Output is correct
20 Correct 1 ms 336 KB Output is correct