Submission #228428

#TimeUsernameProblemLanguageResultExecution timeMemory
228428s_avila_gGarage (IOI09_garage)C++14
0 / 100
320 ms444 KiB
#include <bits/stdc++.h> using namespace std; queue<int> col; map<int,int> mp; int main(){ freopen("in.txt","r",stdin); freopen("out.txt","w",stdout); int n,m; cin>>n>>m; vector<int> parks(n); vector<int> cars(n); for(int i = 0 ; i < n; i++)cin>>parks[i]; for(int i = 0 ; i < m; i++)cin>>cars[i]; int vis[n]; memset(vis,0,sizeof vis); int ans = 0; for(int i = 0 ; i < (2*m); i++){ int x; cin>>x; bool libre = false; if(x > 0){ int pos; for(int j = 0; j < n; j++){ if(vis[j] == 0){ libre = true; pos = j; break; } } if(!libre){ col.push(x); }else{ mp[x] = pos; ans += cars[x-1] * parks[pos]; vis[pos] = 1; } }else{ vis[mp[abs(x)]] = 0; if(!col.empty()){ int nxt = col.front(); vis[mp[abs(x)]] = 1; col.pop(); ans += cars[nxt-1] * parks[mp[abs(x)]]; } mp[abs(x)] = -1; } } cout<<ans<<endl; }

Compilation message (stderr)

garage.cpp: In function 'int main()':
garage.cpp:7:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen("in.txt","r",stdin);
     ~~~~~~~^~~~~~~~~~~~~~~~~~~~
garage.cpp:8:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen("out.txt","w",stdout);
     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...