제출 #275141

#제출 시각아이디문제언어결과실행 시간메모리
275141Bill_00Garage (IOI09_garage)C++14
100 / 100
2 ms384 KiB
#include <bits/stdc++.h> typedef long long ll; const ll inf=1000000000000000000; #define fr(i,c,d) for(ll i=c;i<=d;i++) #define MOD 1000000007 #define ff first #define ss second #define pb push_back #define mp make_pair #define pp push using namespace std; const int sz=173; string str(string x,int l,int r){ string h; for(int i=l;i<=r;i++){ h+=x[i]; } return h; } int main(){ //int color[200001]; ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ll n,m; cin >> n >> m; ll a[101]={0},b[101]; ll r[101]; ll w[2001]; for(int i=1;i<=n;i++){ cin >> r[i]; } for(int i=1;i<=m;i++){ cin >> w[i]; } ll ans=0; queue<ll>q; for(int i=1;i<=2*m;i++){ ll car,flag=0; cin >> car; if(car>0){ for(int j=1;j<=n;j++){ if(a[j]==0){ ans+=(w[car]*r[j]); a[j]=car; flag++; break; } } if(flag==0){ q.pp(car); } } else{ car=-car; for(int i=1;i<=n;i++){ if(a[i]==car){ a[i]=0; } } if(!q.empty()){ for(int i=1;i<=n;i++){ if(a[i]==0){ a[i]=q.front(); q.pop(); ans+=(r[i]*w[a[i]]); break; } } } } } cout << ans; }

컴파일 시 표준 에러 (stderr) 메시지

garage.cpp: In function 'int main()':
garage.cpp:27:16: warning: unused variable 'b' [-Wunused-variable]
   27 |  ll a[101]={0},b[101];
      |                ^
#Verdict Execution timeMemoryGrader output
Fetching results...