Submission #400388

#TimeUsernameProblemLanguageResultExecution timeMemory
400388abdzagCloud Computing (CEOI18_clo)C++17
0 / 100
113 ms262148 KiB
#include<bits/stdc++.h> #include<unordered_map> #define rep(i,a,b) for(int i=int(a);i<int(b);i++) #define rrep(i,a,b) for(int i=int(a);i>int(b);i--) #define all(v) v.begin(),v.end() #define trav(a,v) for(auto&a:v) #define sz(a) a.size() typedef long double ld; using namespace std; const long long inf = 1e15; typedef long long ll; typedef unsigned long long ull; int main() { cin.sync_with_stdio(false); ll n,m; cin >> n; vector<pair<pair<ll, ll>, pair<ll, ll>>> v(n); rep(i, 0, n) { cin >> v[i].second.first >> v[i].first.first >> v[i].second.second; v[i].first.first *= -1; } cin >> m; v.resize(n + m); rep(i, n, n+m) { cin >> v[i].second.first >> v[i].first.first >> v[i].second.second; v[i].first.first *= -1; v[i].first.second = 1; } sort(all(v)); vector<vector<ll>>dp(m+n+1,vector<ll>(2e5, -inf)); dp[0][0] = 0; ll sumc = 1; rep(i, 0, n+m) { rep(j, 0, sumc) { if (!v[i].first.second) { if (dp[i][j] != -inf)if(v[i].second.first + j<dp[0].size())dp[i+1][v[i].second.first + j] = max(dp[i][v[i].second.first + j], dp[i][j]-v[i].second.second); } else { if (dp[i][j] != -inf)if (-v[i].second.first + j >= 0)dp[i+1][-v[i].second.first + j] = max(dp[i][-v[i].second.first + j], dp[i][j] + v[i].second.second); } dp[i + 1][j] = max(dp[i][j], dp[i + 1][j]); } sumc += v[i].second.first; } ll ans = 0; rep(i, 0, 2e5)ans = max(dp[m+n][i], ans); cout<<ans; return 0; }

Compilation message (stderr)

clo.cpp: In function 'int main()':
clo.cpp:38:62: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |                 if (dp[i][j] != -inf)if(v[i].second.first + j<dp[0].size())dp[i+1][v[i].second.first + j] = max(dp[i][v[i].second.first + j], dp[i][j]-v[i].second.second);
#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...