Submission #431111

#TimeUsernameProblemLanguageResultExecution timeMemory
431111SAADGarage (IOI09_garage)C++17
20 / 100
5 ms332 KiB
#define F first #define S second #define rep(i,a,b) for(int i=a;!(a==b&&i!=b)&&((i<=b&&b>=a)||(i>=b&&a>=b));i+=(a<=b?1:-1)) #define pb push_back #define Fbitl __builtin_ffs #define bit1 __builtin_popcount //#include <bits/stdc++.h> #include <iostream> #include <math.h> #include <algorithm> #include <string.h> #include <vector> #include <queue> #include <map> #include <unordered_map> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<string, string> pss; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<pii> vii; typedef vector<ll> vl; typedef vector<vl> vvl; int arr[(int)1e5] , car[(int)1e5] , pos[(int)1e5]; bool visa[1002]; int main() { int n, m; ll ans = 0; cin >> n >> m; for (int i = 0; i < n; i++) { cin >> arr[i]; visa[arr[i]] = true; } queue <int> q; int c = 0 , p ; for (int i = 1; i <= m; i++) { cin >> car[i]; } for (int j = 0; j < m*2; j++) { cin >> p; if (p < 0) { p = -p; visa[pos[p]] = true; if (q.size()) { pos[q.front()] = pos[p]; visa[pos[p]] = false; ans += pos[p] * car[q.front()]; q.pop(); } } else { if (q.size()) q.push(p); else for (int i = 0; i <= 100;i++) { if ( visa[arr[i]] ) { visa[arr[i]] = false; pos[p] = arr[i]; ans += arr[i] * car[p]; break; } if (i == 100) q.push(p); } } } cout << ans; return 0; }

Compilation message (stderr)

garage.cpp: In function 'int main()':
garage.cpp:38:6: warning: unused variable 'c' [-Wunused-variable]
   38 |  int c = 0 , p ;
      |      ^
#Verdict Execution timeMemoryGrader output
Fetching results...