제출 #232926

#제출 시각아이디문제언어결과실행 시간메모리
232926ZexGarage (IOI09_garage)C++11
100 / 100
5 ms384 KiB
#include<bits/stdc++.h> using namespace std; #define LL long long #define INF INT_MAX #define LD long double #define endl '\n' #define output for(LL i=0;i<sizex;i++) { for(LL j=0;j<sizey;j++) { cout << A[i][j] << " "; }cout<<endl; }cout<<endl; const int maxN = 101, maxM = 2001; int N, M; int RATE[maxN]; int WEIGHT[maxM]; bool TAKEN[maxN] = {}; int takenSpace[maxM] = {}; int takenSpaces = 0; int PROFIT = 0; queue <int> q; void enter( int car ){ if( takenSpaces == N ) return q.push(car); for(int i=1;i<=N;i++){ if( TAKEN[i] ) continue; takenSpace[car] = i; TAKEN[i] = true; PROFIT += RATE[i]*WEIGHT[car]; takenSpaces++; // cout << "Car " << car << " entered in lane " << i << "(" << RATE[i]*WEIGHT[car] << ")" << endl; return; } cout << "uhhh brat?" << endl; } void leave( int car ){ if( !takenSpace[car] ){ cout << "uhhh brat?" << endl; return; } takenSpaces--; TAKEN[takenSpace[car]] = false; // cout << "Car " << car << " left lane " << takenSpace[car] << endl; takenSpace[car] = 0; while( takenSpaces < N && !q.empty() ){ enter( q.front() ); q.pop(); } } int main(){ ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> N >> M; for(int i=1;i<=N;i++) cin >> RATE[i]; for(int i=1;i<=M;i++) cin >> WEIGHT[i]; for(int i=0;i<2*M;i++){ int CAR; cin >> CAR; if( CAR < 0 ) leave( -CAR ); else enter( CAR ); } cout << PROFIT << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...