# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
647113 | ghostwriter | Cloud Computing (CEOI18_clo) | C++14 | 1710 ms | 3556 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include <debug.h>
#else
#define debug(...)
#endif
#define ft front
#define bk back
#define st first
#define nd second
#define ins insert
#define ers erase
#define pb push_back
#define pf push_front
#define _pb pop_back
#define _pf pop_front
#define lb lower_bound
#define ub upper_bound
#define mtp make_tuple
#define bg begin
#define ed end
#define all(x) (x).bg(), (x).ed()
#define sz(x) (int)(x).size()
typedef long long ll; typedef unsigned long long ull;
typedef double db; typedef long double ldb;
typedef pair<int, int> pi; typedef pair<ll, ll> pll;
typedef vector<int> vi; typedef vector<ll> vll; typedef vector<pi> vpi; typedef vector<pll> vpll;
typedef string str;
template<typename T> T gcd(T a, T b) { return (b == 0? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
#define FOS(i, r, l) for (int (i) = (r); (i) >= (l); --(i))
#define FRN(i, n) for (int (i) = 0; (i) < (n); ++(i))
#define FSN(i, n) for (int (i) = (n) - 1; (i) >= 0; --(i))
#define EACH(i, x) for (auto &(i) : (x))
#define WHILE while
#define file "TEST"
mt19937 rd(chrono::steady_clock::now().time_since_epoch().count());
ll rand(ll l, ll r) { return uniform_int_distribution<ll>(l, r)(rd); }
/*
----------------------------------------------------------------
END OF TEMPLATE
----------------------------------------------------------------
Tran The Bao - ghostwriter
Training for VOI23 gold medal
----------------------------------------------------------------
DIT ME CHUYEN BAO LOC
----------------------------------------------------------------
*/
struct Computer {
int c, f, v;
Computer() {}
Computer(int c, int f, int v) : c(c), f(f), v(v) {}
};
#define Client Computer
bool cmp(Computer &a, Computer &b) { return a.f < b.f; }
const int N = 2001;
const int C = 51;
int n, m;
Computer a[N];
Client b[N];
ll d[N][C][2], d1[N][C][2];
signed main() {
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
// freopen(file".inp", "r", stdin);
// freopen(file".out", "w", stdout);
cin >> n;
FOR(i, 1, n) cin >> a[i].c >> a[i].f >> a[i].v;
cin >> m;
FOR(i, 1, m) cin >> b[i].c >> b[i].f >> b[i].v;
sort(a + 1, a + 1 + n, cmp);
sort(b + 1, b + 1 + m, cmp);
FOR(i, 1, m) {
FOR(j, 1, n)
FOR(w, 0, 50)
FOR(stat, 0, 1) {
ll &rs = d[j][w][stat];
rs = 0;
if (stat) {
rs = max(rs, d1[j][w][1]);
rs = max(rs, d[j - 1][b[i].c][0]);
if (a[j].f >= b[i].f) {
if (w < b[i].c) rs = max(rs, d[j - 1][b[i].c - w][0] - (w < a[j].c? 0 : a[j].v));
else rs = max(rs, d1[j][w - b[i].c][1] + b[i].v - (w < a[j].c? 0 : a[j].v));
}
}
else {
rs = max(rs, d[j - 1][w][0]);
if (a[j].f >= b[i].f) {
if (a[j].c < w) rs = max(rs, d[j - 1][w - a[j].c][0] - a[j].v);
else if (w) rs = max(rs, d1[j][a[j].c - w][1] + b[i].v - a[j].v);
}
}
}
FOR(j, 1, n)
FOR(w, 0, 50)
FOR(stat, 0, 1)
d1[j][w][stat] = d[j][w][stat];
}
cout << d[n][a[n].c][1];
return 0;
}
/*
4
4 2200 700
2 1800 10
20 2550 9999
4 2000 750
3
1 1500 300
6 1900 1500
3 2400 4550
----------------------------------------------------------------
From Benq:
stuff you should look for
* int overflow, array bounds
* special cases (n=1?)
* do smth instead of nothing and stay organized
* WRITE STUFF DOWN
* DON'T GET STUCK ON ONE APPROACH
----------------------------------------------------------------
*/
컴파일 시 표준 에러 (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... |