제출 #951675

#제출 시각아이디문제언어결과실행 시간메모리
951675GithubCloud Computing (CEOI18_clo)C++17
100 / 100
747 ms2296 KiB
#include <iostream> #include <vector> #include <queue> #include <cstring> #include <map> #include <climits> #include <cmath> #include <algorithm> #include <stack> #include <set> using namespace std; #define speedup ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); #define ll long long #define pr printf #define sc scanf #define fi first #define si second const ll MOD = 998244353; const ll INF = 1e17; void setIO(string s){ freopen((s+".in").c_str(), "r", stdin); freopen((s+".out").c_str(), "w", stdout); } struct Event{ ll c, f, v; }; int main() { speedup int n; cin >> n; vector<Event> a; ll mx = 0; for (int i = 0; i < n; i++){ ll ci, f, v; cin >> ci >> f >> v; mx += ci; a.push_back({ci, f, -v}); } int m; cin >> m; for (int i = 0; i < m; i++){ ll c, f, v; cin >> c >> f >> v; a.push_back({-c, f, v}); } auto cmp = [&](Event x, Event y){ return (x.f == y.f ? x.v < y.v: x.f > y.f); }; sort(a.begin(), a.end(), cmp); vector<ll> oldDP(mx+1, LLONG_MIN); oldDP[0] = 0; for (Event& x: a){ vector<ll> newDP(oldDP); for (ll c = 0; c <= mx; c++){ ll p = c - x.c; if (0 <= p && p <= mx && oldDP[p] != LLONG_MIN){ newDP[c] = max(newDP[c], oldDP[p]+x.v); } } oldDP = newDP; } cout << *max_element(oldDP.begin(), oldDP.end()) << endl; return 0; }

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

clo.cpp: In function 'void setIO(std::string)':
clo.cpp:25:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |     freopen((s+".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
clo.cpp:26:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |     freopen((s+".out").c_str(), "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...