# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
287380 | 2020-08-31T16:34:04 Z | Namnamseo | Garage (IOI09_garage) | C++17 | 2 ms | 384 KB |
#include <cstdio> #include <cstdlib> int sc[2010]; int ww[2010]; int place[2010]; int who [2010]; int n,m; int queue[2010]; int h,t; int main() { int income=0; scanf("%d%d",&n,&m); for(int i=1; i<=n; ++i) scanf("%d",sc+i); for(int i=1; i<=m; ++i) scanf("%d",ww+i); int a; int filled=0; for(int _=1; _<=2*m; ++_){ scanf("%d",&a); if(a>0){ queue[h++]=a; } else { a=-a; who[place[a]]=0; place[a]=0; --filled; } while(filled<n && t<h){ int i; for(i=1; i<=n; ++i){ if(who[i]==0) break; } who[i]=queue[t]; place[queue[t]]=i; income += sc[i]*ww[who[i]]; ++filled; ++t; } } printf("%d\n",income); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 1 ms | 256 KB | Output is correct |
5 | Correct | 0 ms | 256 KB | Output is correct |
6 | Correct | 0 ms | 256 KB | Output is correct |
7 | Correct | 0 ms | 256 KB | Output is correct |
8 | Correct | 1 ms | 256 KB | Output is correct |
9 | Correct | 1 ms | 256 KB | Output is correct |
10 | Correct | 1 ms | 256 KB | Output is correct |
11 | Correct | 1 ms | 384 KB | Output is correct |
12 | Correct | 1 ms | 384 KB | Output is correct |
13 | Correct | 1 ms | 384 KB | Output is correct |
14 | Correct | 1 ms | 384 KB | Output is correct |
15 | Correct | 1 ms | 384 KB | Output is correct |
16 | Correct | 1 ms | 384 KB | Output is correct |
17 | Correct | 1 ms | 384 KB | Output is correct |
18 | Correct | 1 ms | 384 KB | Output is correct |
19 | Correct | 1 ms | 384 KB | Output is correct |
20 | Correct | 2 ms | 384 KB | Output is correct |