답안 #445040

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
445040 2021-07-16T09:56:45 Z cpp219 Garage (IOI09_garage) C++14
40 / 100
2 ms 332 KB
#pragma GCC optimization O2
#pragma GCC optimization "unroll-loop"
#pragma target ("avx2")

#include <bits/stdc++.h>
#define ll long long
#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];
            }
        }
    }
    cout<<ans;
}

Compilation message

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);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Correct 0 ms 204 KB Output is correct
4 Incorrect 0 ms 204 KB Output isn't correct
5 Correct 1 ms 204 KB Output is correct
6 Incorrect 1 ms 204 KB Output isn't correct
7 Correct 1 ms 204 KB Output is correct
8 Incorrect 0 ms 204 KB Output isn't correct
9 Correct 0 ms 204 KB Output is correct
10 Incorrect 0 ms 204 KB Output isn't correct
11 Correct 1 ms 204 KB Output is correct
12 Incorrect 1 ms 332 KB Output isn't correct
13 Correct 1 ms 332 KB Output is correct
14 Incorrect 1 ms 332 KB Output isn't correct
15 Correct 1 ms 332 KB Output is correct
16 Incorrect 1 ms 332 KB Output isn't correct
17 Incorrect 1 ms 332 KB Output isn't correct
18 Incorrect 1 ms 332 KB Output isn't correct
19 Incorrect 1 ms 332 KB Output isn't correct
20 Incorrect 2 ms 332 KB Output isn't correct