# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
585522 | 2022-06-29T03:53:03 Z | krit3379 | Garage (IOI09_garage) | C++17 | 1 ms | 340 KB |
#include<bits/stdc++.h> using namespace std; #define N 2005 #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") int l[N],r[N],w[N],sz,ans; bitset<N> park; queue<int> q; int main(){ int n,m,i,j,x; scanf("%d %d",&n,&m); for(i=1;i<=n;i++)scanf("%d",&r[i]); for(i=1;i<=m;i++)scanf("%d",&w[i]); sz=n; for(i=1;i<=(m<<1);i++){ scanf("%d",&x); if(x>0)q.push(x); else sz++,park[l[-x]]=false; while(!q.empty()&&sz){ for(j=1;j<=n;j++)if(!park[j]){park[j]=true,sz--,l[q.front()]=j,ans+=r[j]*w[q.front()];break;} q.pop(); } } printf("%d",ans); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 304 KB | Output is correct |
2 | Correct | 1 ms | 304 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 300 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 1 ms | 340 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 340 KB | Output is correct |
20 | Correct | 1 ms | 340 KB | Output is correct |