Submission #994607

# Submission time Handle Problem Language Result Execution time Memory
994607 2024-06-08T02:23:00 Z ducksaysquack Garage (IOI09_garage) C++
100 / 100
1 ms 348 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
	ios::sync_with_stdio(0); cin.tie(0);
	int n, k; cin >> n >> k; vector<int> a(n), b(k), c(k);
	for(int i=0;i<n;i++) cin >> a[i]; for(int i=0;i<k;i++) cin >> b[i];
	set<int> s; queue<int> q; int ans = 0;
	for(int i=0;i<n;i++) s.insert(i);
	for(int i=0;i<2*k;i++) {
		int x; cin >> x; if(x<0) s.insert(c[-x-1]); else q.push(x-1);
		while(!s.empty()&&!q.empty()) {
			int y = q.front(); ans += a[*s.begin()]*b[y], c[y]=*s.begin(); 
			s.erase(s.begin()); q.pop();
		}
	}
	cout << ans;
}

Compilation message

garage.cpp: In function 'int main()':
garage.cpp:7:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
    7 |  for(int i=0;i<n;i++) cin >> a[i]; for(int i=0;i<k;i++) cin >> b[i];
      |  ^~~
garage.cpp:7:36: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
    7 |  for(int i=0;i<n;i++) cin >> a[i]; for(int i=0;i<k;i++) cin >> b[i];
      |                                    ^~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct