Submission #1114591

#TimeUsernameProblemLanguageResultExecution timeMemory
1114591akacool445kCloud Computing (CEOI18_clo)C++17
100 / 100
652 ms2304 KiB
#include <bits/stdc++.h> using namespace std; #define ff first #define ss second #define pb push_back #define int long long #define pint pair<int, int> #define vint vector<pair<int, int>> const int mod = 1e9 + 7; const int shrek = 4000 * 20; const int say = INT_MAX; const int gex = INT_MIN; const long long oo = 1e18; bool cmp(const array<int, 3>&a, const array<int, 3>&b) { if(a[0] != b[0]) return a[0] > b[0]; else return a[1] < b[1]; } signed main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); vector<array<int, 3>> v; int n; cin >> n; int maxi = 0; for(int i = 0; i < n; i++) { int a, b , c; cin >> a >> b >> c; v.pb({b, -c, a}); maxi += a; } int m; cin >> m; for(int i = 0; i < m; i++) { int a, b, c; cin >> a >> b >> c; v.pb({b, c, -a}); } int pre[maxi + 1]; int cur[maxi + 1]; sort(v.begin(), v.end(), cmp); // reverse(v.begin(), v.end()); // int len = n + m; for(int j = 0; j <= maxi; j++) { pre[j] = LLONG_MIN; } pre[0] = 0; for(int i = 0; i < v.size(); i++) { for(int j = 0; j <= maxi; j++) cur[j] = pre[j]; for(int j = 0; j <= maxi; j++) { int l = j - v[i][2]; if(0 <= l && l <= maxi && pre[l] != LLONG_MIN) { cur[j] = max(cur[j], pre[l] + v[i][1]); } } for(int j = 0; j <= maxi; j++) pre[j] = cur[j]; } int gayans = LLONG_MIN; for(int j = 0; j <= maxi; j++) { gayans = max(gayans, pre[j]); } cout << gayans << '\n'; return 0; }

Compilation message (stderr)

clo.cpp: In function 'int main()':
clo.cpp:44:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::array<long long int, 3> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |     for(int i = 0; i < v.size(); i++) {
      |                    ~~^~~~~~~~~~
#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...