Submission #445042

#TimeUsernameProblemLanguageResultExecution timeMemory
445042cpp219Garage (IOI09_garage)C++14
100 / 100
2 ms332 KiB
#pragma GCC optimization O2 #pragma GCC optimization "unroll-loop" #pragma target ("avx2") #include <bits/stdc++.h> #define ll int #define ld long double #define fs first #define sc second using namespace std; typedef pair<ll,ll> LL; const ll N = 2000 + 9; const ll Log2 = 30; const ll mod = 1e9 + 7; priority_queue<ll,vector<ll>,greater<ll>> spare; queue<ll> wait; ll n,m,R[N],a[N],x,take[N]; int main(){ ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0); #define task "tst" if (fopen(task".INP","r")){ freopen(task".INP","r",stdin); //freopen(task".OUT","w",stdout); } ll ans = 0; cin>>n>>m; for (ll i = 1;i <= n;i++) cin>>R[i],spare.push(i); for (ll i = 1;i <= m;i++) cin>>a[i]; for (ll i = 1;i <= 2*m;i++){ cin>>x; if (x > 0){ if (!spare.empty()){ ll now = spare.top(); spare.pop(); take[x] = now; ans += R[now] * a[x]; } else wait.push(x); } else{ x = -x; ll now = take[x]; spare.push(now); while (!wait.empty() && !spare.empty()){ ll place = spare.top(); spare.pop(); ll car = wait.front(); wait.pop(); ans += R[place] * a[car]; take[car] = place; } } } cout<<ans; }

Compilation message (stderr)

garage.cpp:1: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    1 | #pragma GCC optimization O2
      | 
garage.cpp:2: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    2 | #pragma GCC optimization "unroll-loop"
      | 
garage.cpp:3: warning: ignoring '#pragma target ' [-Wunknown-pragmas]
    3 | #pragma target ("avx2")
      | 
garage.cpp: In function 'int main()':
garage.cpp:24:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |         freopen(task".INP","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...