# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1026087 | coolsentenceidontremember | Cloud Computing (CEOI18_clo) | C++17 | 610 ms | 2140 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#pragma GCC optimize("O3", "unroll-loops")
#define ll long long
#define ld long double
#define ff first
#define ss second
#define db double
#define time_begin() auto begin = chrono::high_resolution_clock::now()
#define time_end() auto end = chrono::high_resolution_clock::now(); auto elapsed = chrono::duration_cast<chrono::nanoseconds>(end-begin); auto sec = elapsed.count() * 1e-9; cerr << "\n\nExecution time: " << sec << " seconds";
#define check_time() cerr << "\nStatus : "; if (sec>1) cerr << "Time Limit Exceeded 1!!!1!111"; else cerr << "You good brother"
using namespace std;
void setIO(string s = ""){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
if (!s.empty()){
freopen((s+".in").c_str(), "r", stdin);
freopen((s+".out").c_str(), "w", stdout);
}
}
const auto inf = LLONG_MAX;
const ll mod = 1e9 + 7;
ll pow_mod(ll a, ll b, ll m = mod){
if (!a) return 0;
a %= mod; ll res = 1;
for (;b;b>>=1, a = (a*a)%mod){
if (b&1) res = (res*a)%mod;
}
return res;
}
struct obj{
bool computer;
int core;
int clock;
ll profit;
};
bool cmp(const obj &a, const obj&b){
if (a.clock != b.clock) return a.clock > b.clock;
else if (a.computer != b.computer) return (a.computer);
else if (!a.computer) return a.profit > b.profit;
else return a.profit < b.profit;
}
int main(){
setIO();
int n;
cin >> n;
vector<obj> v;
int total_core = 0;
for (int i=1; i <= n; i++){
obj c;
cin >> c.core >> c.clock >> c.profit;
c.computer = 1;
total_core += c.core;
v.push_back(c);
}
int m;
cin >> m;
for (int i = 1; i <= m; i++){
obj o;
cin >> o.core >> o.clock >> o.profit;
o.computer = 0;
v.push_back(o);
}
sort(v.begin(), v.end(), cmp);
vector<ll> dp1(total_core+1, -inf);
dp1[0] = 0;
for (int i = 0; i < n+m; i++){
obj cur = v[i];
vector<ll> dp2(dp1);
if (cur.computer) cur.profit = -cur.profit;
else cur.core = -cur.core;
for (int c = 0; c <= total_core; c++){
int past = c - cur.core;
if (past >= 0 && past <= total_core && dp1[past] != -inf){
// cout << i << ' ' << c << ' ' << past << ' ' << cur.profit << ' ' << dp1[past] << '\n';
dp2[c] = max(dp2[c], dp1[past] + cur.profit);
}
}
dp1 = dp2;
}
cout << *max_element(dp1.begin(), dp1.end()) << '\n';
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |