제출 #155508

#제출 시각아이디문제언어결과실행 시간메모리
155508karmaGarage (IOI09_garage)C++14
100 / 100
4 ms504 KiB
#include<bits/stdc++.h> #define Task "test" #define pb emplace_back using namespace std; const int N = 2002; int w[N], r[N], n, m, res, id, pos[N]; priority_queue<int, vector<int>, greater<int>> pq; queue<int> q; int main() { ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0); if(fopen(Task".inp", "r")) { freopen(Task".inp", "r", stdin); freopen(Task".out", "w", stdout); } cin >> n >> m; for(int i = 1; i <= n; ++i) cin >> r[i], pq.push(i); for(int i = 1; i <= m; ++i) cin >> w[i]; for(int i = 1; i <= 2 * m; ++i) { cin >> id; if(id > 0) q.push(id); else pq.push(pos[-id]); while(pq.size() && q.size()) { id = q.front(); q.pop(); pos[id] = pq.top(); pq.pop(); res += w[id] * r[pos[id]]; } } cout << res; }

컴파일 시 표준 에러 (stderr) 메시지

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