Submission #358564

#TimeUsernameProblemLanguageResultExecution timeMemory
358564Sparky_09Cloud Computing (CEOI18_clo)C++17
72 / 100
392 ms1260 KiB
#include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for(int i = a; i < (b); ++i) #define all(x) begin(x), end(x) #define sz(x) (int)(x).size() typedef long long ll; typedef pair<ll, ll> pii; typedef vector<ll> vi; typedef vector<pii> vpi; void usaco(string s){ freopen((s+".in").c_str(), "r", stdin); freopen((s+".out").c_str(), "w", stdout); } const int maxn = 2e3 + 5; ll dp[maxn * 50]; struct object{ int c , f , v; bool operator < (const object & other){ //if(f == other.f)return v < other.v; return f > other.f; } }a[maxn * 2]; int n , m; int main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); #ifdef LOCAL_DEFINE freopen("input.txt", "r", stdin); #endif cin >> n; for(int i = 1 ; i <= n ; ++i){ cin >> a[i].c >> a[i].f >> a[i].v; a[i].v = -a[i].v; } cin >> m; for(int i = 1 ; i <= m ; ++i){ cin >> a[i + n].c >> a[i + n].f >> a[i + n].v; } sort(a + 1 , a + n + m + 1); fill_n(&dp[0],maxn*50,-1e18); dp[0] = 0; for(int i = 1 ; i <= n + m ; ++i){ if(a[i].v < 0){ for(int j = 100000 - a[i].c ; j >= 0 ; --j){ dp[j + a[i].c] = max(dp[j + a[i].c] , dp[j] + a[i].v); } }else{ for(int j = a[i].c ; j <= 100000 ; ++j){ dp[j - a[i].c] = max(dp[j - a[i].c] , dp[j] + a[i].v); } } } cout << *max_element(dp,dp+maxn*50); }

Compilation message (stderr)

clo.cpp: In function 'void usaco(std::string)':
clo.cpp:12:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   12 |   freopen((s+".in").c_str(), "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
clo.cpp:13:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   13 |   freopen((s+".out").c_str(), "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...