Submission #994607

#TimeUsernameProblemLanguageResultExecution timeMemory
994607ducksaysquackGarage (IOI09_garage)C++98
100 / 100
1 ms348 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...