Submission #275825

#TimeUsernameProblemLanguageResultExecution timeMemory
275825barsboldGarage (IOI09_garage)C++14
35 / 100
2 ms512 KiB
#include<bits/stdc++.h> #define pb push_back #define mp make_pair #define ff first #define ss second using namespace std; int r[101]; int w[101]; int s[202]; int vis[101]; int res =0; int n , m; int main(){ cin >> n; cin >>m; memset(vis , 0 , sizeof(vis)); vector<int> wait; for(int i = 1; i<=n; i++){ cin >> r[i]; } for(int i = 1; i<=m; i++){ cin >> w[i]; } for(int i = 1; i<=m * 2; i++){ int tmp; cin >> tmp; if(tmp > 0){ bool flag =true; for(int i = 1; i<=n; i++){ if(vis[i] == 0){ res+=r[i] * w[tmp]; vis[i] = tmp; flag = false; break; } } if(flag) wait.pb(tmp); } else { int sul ; for(int i = 1; i<=n; i++){ if(vis[i] == tmp * (-1)){ vis[i] = 0; sul = i; } } if(wait.size()!=0) { res+=w[wait[0]] * r[sul]; wait.erase(wait.begin()); } } } cout << res << endl; return 0; }

Compilation message (stderr)

garage.cpp: In function 'int main()':
garage.cpp:51:28: warning: 'sul' may be used uninitialized in this function [-Wmaybe-uninitialized]
   51 |     res+=w[wait[0]] * r[sul];
      |                       ~~~~~^
#Verdict Execution timeMemoryGrader output
Fetching results...