Submission #99197

#TimeUsernameProblemLanguageResultExecution timeMemory
99197figter001Garage (IOI09_garage)C++14
0 / 100
3 ms384 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef unsigned long long ull; const ll oo = 1e18; const ll mod = 1e9+7; const int nax = 110; const int mx = 2010; ll r[nax],w[mx],at[mx]; int main(){ #ifndef ONLINE_JUDGE freopen("input.txt","r",stdin); #endif int n,m; cin>>n>>m; set<int> st; for(int i=1;i<=n;i++){ st.insert(i); cin>>r[i]; } for(int i=1;i<=m;i++) cin>>w[i]; ll ans = 0; queue<int> q; for(int i=1;i<=2*m;i++){ int t; cin>>t; if(t > 0){ q.push(t); }else{ t = -t; st.insert(at[t]); } while(q.size() && st.size()){ t = q.front(); q.pop(); at[t] = *st.begin(); ans += w[t] * r[at[t]]; st.erase(st.begin()); } } cout << ans << endl; }

Compilation message (stderr)

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