Submission #1290883

#TimeUsernameProblemLanguageResultExecution timeMemory
1290883vuvietCloud Computing (CEOI18_clo)C++20
18 / 100
227 ms836 KiB
/** * __ __ __ __ * \ \ / / \ \ / (_) _____ * \ \ / /_ _\ \ / / _ ___|_ _| * \ \/ /| | | |\ \/ / | |/ _ \ | | * \ / | |_| | \ / | | __/ | | * \/ \__,_| \/ |_|\____||_| * * Author: ~Noah's Ark~ * Born on: 2024-24-03 11:15 **/ #include <bits/stdc++.h> #define ____vuviet__ signed main #define taskname "CLOUDCOMPUTING" using namespace std; using lli = long long; using ull = unsigned long long; using pii = pair<int, int>; using pll = pair<lli, lli>; #define fi first #define se second #define pb push_back #define eb emplace_back #define all(x) x.begin(), x.end() #define bs binary_search #define lb lower_bound #define ub upper_bound #define GetBit(x, k) ((x >> k) & 1) #define OnBit(x, k) (x | (1LL << k)) #define OffBit(x, k) (x & ~(1LL << k)) #define FlipBit(x, k) (x ^ (1LL << k)) constexpr int maxn = 1e5 + 5; constexpr int mod = 1e9 + 7; constexpr long long inf = 9e18; struct Cloud { int c, f, v, id; bool operator < (Cloud o) const { return (f == o.f) ? (id < o.id) : f > o.f; } }; void SetupEnviroment() { if (fopen(taskname ".inp", "r")) { freopen(taskname ".inp", "r", stdin); freopen(taskname ".out", "w", stdout); } } void SolvebyNoahzArk() { int n, m; cin >> n; vector<Cloud> cloud; for (int i = 1; i <= n; ++i) { int c, f, v; cin >> c >> f >> v; cloud.pb({c, f, v, i}); } cin >> m; for (int i = n + 1; i <= n + m; ++i) { int c, f, v; cin >> c >> f >> v; cloud.pb({c, f, v, i}); } vector<int> dp(100'000 + 1, -mod); dp[0] = 0; sort(all(cloud)); for (Cloud x : cloud) { if (x.id <= n) { for (int j = 100'000; j >= x.c; --j) dp[j] = max(dp[j], dp[j - x.c] - x.v); } else { for (int j = 0; j <= 100'000 - x.c; ++j) dp[j] = max(dp[j], dp[j + x.c] + x.v); } } cout << *max_element(all(dp)); } ____vuviet__() { ios_base::sync_with_stdio(false); cin.tie(nullptr); SetupEnviroment(); int t = 1; while (t-- > 0) SolvebyNoahzArk(); return 0; }

Compilation message (stderr)

clo.cpp: In function 'void SetupEnviroment()':
clo.cpp:53:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   53 |         freopen(taskname ".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
clo.cpp:54:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   54 |         freopen(taskname ".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...