제출 #733927

#제출 시각아이디문제언어결과실행 시간메모리
733927vjudge1Garage (IOI09_garage)C++98
100 / 100
3 ms340 KiB
#include<bits/stdc++.h> using namespace std; int main() { unsigned long long s=0; int n,m,k=0,p=0,q=0; cin>>n>>m; int a[n][2],c[m], l[m*2],w[m]; for(int i=0; i<n; i++) { cin>>a[i][0]; a[i][1]=0; } for(int j=0; j<m; j++) cin>>c[j]; int j=0; for(int i=0; i<m*2; i++) cin>>l[i]; for(int i=0; i<m*2; i++) { if(l[i]>0) { if(k>=n) { w[p]=l[i]; p++; } else{ for(int j=0; j<n; j++) { if(a[j][1]==0) { a[j][1]=l[i]; s+=c[l[i]-1]*a[j][0]; k++; break; } } } } else { int x=abs(l[i]); for(int j=0; j<n; j++) { if(a[j][1]==x) { if(p>q) { a[j][1]=w[q]; s+=a[j][0]*c[w[q]-1]; q++; } else { a[j][1]=0; k--;} break; } } } } cout<<s; }

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

garage.cpp: In function 'int main()':
garage.cpp:15:6: warning: unused variable 'j' [-Wunused-variable]
   15 |  int j=0;
      |      ^
#Verdict Execution timeMemoryGrader output
Fetching results...