Submission #228588

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