# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
232926 | Zex | Garage (IOI09_garage) | C++11 | 5 ms | 384 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |