제출 #1110518

#제출 시각아이디문제언어결과실행 시간메모리
1110518vjudge1Cloud Computing (CEOI18_clo)C++17
100 / 100
251 ms1528 KiB
#include<bits/stdc++.h> using namespace std; const bool multiTest = false; #define task "C" #define fi first #define se second #define MASK(i) (1LL << (i)) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define BIT(mask, i) ((mask) >> (i) & 1) template<typename T1, typename T2> bool minimize(T1 &a, T2 b) { if (a > b) a = b; else return 0; return 1; } template<typename T1, typename T2> bool maximize(T1 &a, T2 b) { if (a < b) a = b; else return 0; return 1; } struct node { int t, c, f, v; node(int _t = 0, int _c = 0, int _f = 0, int _v = 0) { t = _t; c = _c; f = _f; v = _v; } bool operator< (const node &other) const { if (f != other.f) return f > other.f; return t < other.t; } }; const long long INF = 1e18 + 7; int n, m, sum = 0; node arr[4000]; long long f[100010]; long long g[100010]; void process(void) { cin >> n; for (int i = 0; i < n; ++i) { int c, f, v; cin >> c >> f >> v; arr[i] = node(0, c, f, v); } cin >> m; for (int i = 0; i < m; ++i) { int c, f, v; cin >> c >> f >> v; arr[n + i] = node(1, c, f, v); } for (int i = 0; i <= 100000; ++i) f[i] = -INF; f[0] = 0; sort(arr, arr + n + m); for (int i = 0; i < n + m; ++i) { if (arr[i].t == 0) { sum += arr[i].c; for (int j = sum; j >= arr[i].c; --j) maximize(f[j], f[j - arr[i].c] - arr[i].v); } else { for (int j = 0; j + arr[i].c <= sum; ++j) maximize(f[j], f[j + arr[i].c] + arr[i].v); } } cout << *max_element(f, f + 1 + 100000); } int main(void) { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); if (fopen(task".inp", "r")) { freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } int nTest = 1; if (multiTest) cin >> nTest; while (nTest--) { process(); } return 0; }

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

clo.cpp: In function 'int main()':
clo.cpp:77:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   77 |   freopen(task".inp", "r",  stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
clo.cpp:78:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   78 |   freopen(task".out", "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...