Submission #585522

# Submission time Handle Problem Language Result Execution time Memory
585522 2022-06-29T03:53:03 Z krit3379 Garage (IOI09_garage) C++17
100 / 100
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

garage.cpp: In function 'int main()':
garage.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     scanf("%d %d",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~~
garage.cpp:14:27: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |     for(i=1;i<=n;i++)scanf("%d",&r[i]);
      |                      ~~~~~^~~~~~~~~~~~
garage.cpp:15:27: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     for(i=1;i<=m;i++)scanf("%d",&w[i]);
      |                      ~~~~~^~~~~~~~~~~~
garage.cpp:18:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |         scanf("%d",&x);
      |         ~~~~~^~~~~~~~~
# Verdict Execution time Memory 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