제출 #415060

#제출 시각아이디문제언어결과실행 시간메모리
415060meatrowCloud Computing (CEOI18_clo)C++17
100 / 100
502 ms1228 KiB
// #pragma GCC target ("avx2") #pragma GCC optimization ("O3") #include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; const int MOD = 1e9 + 7; ll binpow(ll a, ll p, int mod = MOD) { ll res = 1; while (p) { if (p & 1) { (res *= a) %= mod; } p >>= 1; (a *= a) %= mod; } return res; } ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); } struct Comp { int cores; ll rate, price; }; bool operator <(const Comp& a, const Comp& b) { return a.rate < b.rate; } void solve() { int n; cin >> n; vector<Comp> computers(n); for (int i = 0; i < n; i++) { cin >> computers[i].cores >> computers[i].rate >> computers[i].price; } sort(computers.begin(), computers.end()); int m; cin >> m; vector<Comp> orders(m); for (int i = 0; i < m; i++) { cin >> orders[i].cores >> orders[i].rate >> orders[i].price; } sort(orders.rbegin(), orders.rend()); int top = n * 50 + 1; vector<ll> dp(top, LLONG_MIN); dp[0] = 0; for (auto& [cores, rate, price] : orders) { while (!computers.empty() && computers.back().rate >= rate) { for (int i = top - 1; i >= computers.back().cores; i--) { if (dp[i - computers.back().cores] == LLONG_MIN) continue; dp[i] = max(dp[i], dp[i - computers.back().cores] - computers.back().price); } computers.pop_back(); } for (int i = 0; i < top - cores; i++) { if (dp[i + cores] == LLONG_MIN) continue; dp[i] = max(dp[i], dp[i + cores] + price); } } cout << *max_element(dp.begin(), dp.end()) << '\n'; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int T = 1; // cin >> T; for (int tc = 1; tc <= T; tc++) { // cout << "Case #" << tc << ": "; solve(); } return 0; }

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

clo.cpp:2: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    2 | #pragma GCC optimization ("O3")
      |
#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...