제출 #871885

#제출 시각아이디문제언어결과실행 시간메모리
871885sanoCloud Computing (CEOI18_clo)C++14
0 / 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 1000000000 #define mod 1000000007 using namespace std; struct tr { int p, h, c; }; bool zorad(tr a, tr b) { if (a.h == b.h) { a.p > b.p; } 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; n = 2000; vec<tr> p; ll c1 = 0; ll c2 = 0; For(i, n) { ll x, y, z; //cin >> x >> y >> z; x = 50; y = 1000000000; z = 999999999; p.push_back({ x, y, -z }); c1 += x; } ll m; //cin >> m; m = 15; vec<tr> o; For(i, m) { ll x, y, z; //cin >> x >> y >> z; x = 50; y = 1000000000; z = 1000000000; 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<int>> dp(n+m + 1, vec<int>(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); } } } int naj = -1; For(i, cc) { naj = max(naj, dp[dp.size() - 1][i]); } cout << naj << endl; return 0; }

컴파일 시 표준 에러 (stderr) 메시지

clo.cpp: In function 'bool zorad(tr, tr)':
clo.cpp:31:7: warning: statement has no effect [-Wunused-value]
   31 |   a.p > b.p;
      |   ~~~~^~~~~
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++)
......
   47 |  For(i, A.size()) {
      |      ~~~~~~~~~~~                   
clo.cpp:47:2: note: in expansion of macro 'For'
   47 |  For(i, A.size()) {
      |  ^~~
clo.cpp: In function 'int main()':
clo.cpp:69:17: warning: narrowing conversion of 'x' from 'long long int' to 'int' [-Wnarrowing]
   69 |   p.push_back({ x, y, -z });
      |                 ^
clo.cpp:69:20: warning: narrowing conversion of 'y' from 'long long int' to 'int' [-Wnarrowing]
   69 |   p.push_back({ x, y, -z });
      |                    ^
clo.cpp:69:23: warning: narrowing conversion of '- z' from 'long long int' to 'int' [-Wnarrowing]
   69 |   p.push_back({ x, y, -z });
      |                       ^~
clo.cpp:82:17: warning: narrowing conversion of '- x' from 'long long int' to 'int' [-Wnarrowing]
   82 |   o.push_back({ -x, y, z });
      |                 ^~
clo.cpp:82:21: warning: narrowing conversion of 'y' from 'long long int' to 'int' [-Wnarrowing]
   82 |   o.push_back({ -x, y, z });
      |                     ^
clo.cpp:82:24: warning: narrowing conversion of 'z' from 'long long int' to 'int' [-Wnarrowing]
   82 |   o.push_back({ -x, y, z });
      |                        ^
clo.cpp:15:39: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 | #define ffor(i, a, n) for(ll i = a; i < n; i++)
......
   97 |  ffor(i, 1, dp.size()) {
      |       ~~~~~~~~~~~~~~~                  
clo.cpp:97:2: note: in expansion of macro 'ffor'
   97 |  ffor(i, 1, dp.size()) {
      |  ^~~~
clo.cpp:99:49: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   99 |    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...