Submission #871878

#TimeUsernameProblemLanguageResultExecution timeMemory
871878sanoCloud Computing (CEOI18_clo)C++14
36 / 100
118 ms262144 KiB
#include <iostream> #include <string> #include <string.h> #include <fstream> #include <algorithm> #include <vector> #include <iomanip> #include <queue> #include<map> #include <stack> #include <unordered_map> #include <set> #define ll long long #define For(i, n) for(ll i = 0; i < n; i++) #define ffor(i, a, n) for(ll i = a; i < n; i++) #define pb push_back #define vec vector #define ff first #define ss second #define pairs pair<ll, ll> #define NEK 1000000000000000000 #define mod 1000000007 using namespace std; struct tr { ll p, h, c; }; bool zorad(tr a, tr b) { if (a.h == b.h) { if (a.p > 0) return true; else return false; } return a.h > b.h; } vec<ll> sitko(ll n) { vec<bool> A; A.resize(n - 2 + 1, true); for (ll i = 2; i * i <= n; i++) { if (A[i - 2]) { for (ll j = i * i; j <= n; j += i) { A[j - 2] = false; } } } vec<ll> prv; For(i, A.size()) { if (A[i]) { prv.push_back(i + 2); } } return prv; } int main() { ll n; cin >> n; vec<tr> p; ll c1 = 0; ll c2 = 0; For(i, n) { ll x, y, z; cin >> x >> y >> z; p.push_back({ x, y, -z }); c1 += x; } ll m; cin >> m; vec<tr> o; For(i, m) { ll x, y, z; cin >> x >> y >> z; o.push_back({ -x, y, z }); c2 += x; } vec<tr> v; For(i, n) { v.push_back(p[i]); } For(i, m) { v.push_back(o[i]); } sort(v.begin(), v.end(), zorad); ll cc = c1+1; vec<vec<ll>> dp(n+m + 1, vec<ll>(cc, (-1)*NEK)); dp[0][0] = 0; ffor(i, 1, dp.size()) { For(j, cc) { if ((j - v[i - 1].p) < 0 || (j - v[i - 1].p) >= dp[i - 1].size()) { dp[i][j] = dp[i - 1][j]; } else { dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - v[i - 1].p] + v[i - 1].c); } } } ll naj = -1; For(i, cc) { naj = max(naj, dp[dp.size() - 1][i]); } cout << naj << endl; return 0; }

Compilation message (stderr)

clo.cpp: In function 'std::vector<long long int> sitko(long long int)':
clo.cpp:14:35: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<bool>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 | #define For(i, n) for(ll i = 0; i < n; i++)
......
   48 |  For(i, A.size()) {
      |      ~~~~~~~~~~~                   
clo.cpp:48:2: note: in expansion of macro 'For'
   48 |  For(i, A.size()) {
      |  ^~~
clo.cpp: In function 'int main()':
clo.cpp:15:39: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 | #define ffor(i, a, n) for(ll i = a; i < n; i++)
......
   90 |  ffor(i, 1, dp.size()) {
      |       ~~~~~~~~~~~~~~~                  
clo.cpp:90:2: note: in expansion of macro 'ffor'
   90 |  ffor(i, 1, dp.size()) {
      |  ^~~~
clo.cpp:92:49: 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]
   92 |    if ((j - v[i - 1].p) < 0 || (j - v[i - 1].p) >= dp[i - 1].size()) {
      |                                ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
#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...