제출 #915636

#제출 시각아이디문제언어결과실행 시간메모리
915636panCloud Computing (CEOI18_clo)C++17
100 / 100
647 ms2336 KiB
#include <bits/stdc++.h> //#include "bits_stdc++.h" #define mp make_pair #define pb push_back #define lb lower_bound #define ub upper_bound #define input(x) scanf("%lld", &x); #define print(x, y) printf("%lld%c", x, y); #define show(x) cerr << #x << " is " << x << endl; #define show2(x,y) cerr << #x << " is " << x << " " << #y << " is " << y << endl; #define show3(x,y,z) cerr << #x << " is " << x << " " << #y << " is " << y << " " << #z << " is " << z << endl; using namespace std; typedef long long ll; typedef long double ld; typedef pair<ld, ll> pd; typedef pair<string, ll> psl; typedef pair<ll, ll> pi; typedef pair<ll, pi> pii; ll n, m;; struct order { ll c, f, v; }; ll const INF = 1e15; bool compare(order a, order b) { if (a.f==b.f) return a.c>0; return a.f>b.f; } int main() { input(n); vector<order> orders(n); ll maxc = 0; for (ll i=0; i<n; ++i) {input(orders[i].c); input(orders[i].f); input(orders[i].v); orders[i].v=-orders[i].v; maxc += orders[i].c;} input(m); orders.resize(n+m); for (ll i=n; i<n+m; ++i) {input(orders[i].c); input(orders[i].f); input(orders[i].v); orders[i].c=-orders[i].c; } sort(orders.begin(), orders.end(), compare); //for (ll i=0; i<n+m; ++i){ cout << orders[i].c << endl;} ll size1 = maxc; vector<ll> prevv(maxc+5, -INF); prevv[0] = 0; ll ans = 0; for (ll i=0; i<n+m; ++i) { //show(i); vector<ll> dp(maxc+5, -INF); for (ll j=0; j<=size1; ++j) { dp[j] = prevv[j]; if (j-orders[i].c>=0 && j-orders[i].c<=size1 && prevv[j-orders[i].c]!=-INF) dp[j] = max(dp[j], prevv[j-orders[i].c] + orders[i].v); ans = max(ans, dp[j]); //show2(j, dp[j]); //show(j-orders[i].c); } swap(dp, prevv); } cout << ans << endl; return 0; }

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

clo.cpp: In function 'int main()':
clo.cpp:8:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 | #define input(x) scanf("%lld", &x);
      |                  ~~~~~^~~~~~~~~~~~
clo.cpp:34:2: note: in expansion of macro 'input'
   34 |  input(n);
      |  ^~~~~
clo.cpp:8:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 | #define input(x) scanf("%lld", &x);
      |                  ~~~~~^~~~~~~~~~~~
clo.cpp:37:26: note: in expansion of macro 'input'
   37 |  for (ll i=0; i<n; ++i) {input(orders[i].c); input(orders[i].f); input(orders[i].v); orders[i].v=-orders[i].v; maxc += orders[i].c;}
      |                          ^~~~~
clo.cpp:8:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 | #define input(x) scanf("%lld", &x);
      |                  ~~~~~^~~~~~~~~~~~
clo.cpp:37:46: note: in expansion of macro 'input'
   37 |  for (ll i=0; i<n; ++i) {input(orders[i].c); input(orders[i].f); input(orders[i].v); orders[i].v=-orders[i].v; maxc += orders[i].c;}
      |                                              ^~~~~
clo.cpp:8:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 | #define input(x) scanf("%lld", &x);
      |                  ~~~~~^~~~~~~~~~~~
clo.cpp:37:66: note: in expansion of macro 'input'
   37 |  for (ll i=0; i<n; ++i) {input(orders[i].c); input(orders[i].f); input(orders[i].v); orders[i].v=-orders[i].v; maxc += orders[i].c;}
      |                                                                  ^~~~~
clo.cpp:8:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 | #define input(x) scanf("%lld", &x);
      |                  ~~~~~^~~~~~~~~~~~
clo.cpp:38:2: note: in expansion of macro 'input'
   38 |  input(m);
      |  ^~~~~
clo.cpp:8:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 | #define input(x) scanf("%lld", &x);
      |                  ~~~~~^~~~~~~~~~~~
clo.cpp:40:28: note: in expansion of macro 'input'
   40 |  for (ll i=n; i<n+m; ++i) {input(orders[i].c); input(orders[i].f); input(orders[i].v); orders[i].c=-orders[i].c; }
      |                            ^~~~~
clo.cpp:8:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 | #define input(x) scanf("%lld", &x);
      |                  ~~~~~^~~~~~~~~~~~
clo.cpp:40:48: note: in expansion of macro 'input'
   40 |  for (ll i=n; i<n+m; ++i) {input(orders[i].c); input(orders[i].f); input(orders[i].v); orders[i].c=-orders[i].c; }
      |                                                ^~~~~
clo.cpp:8:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 | #define input(x) scanf("%lld", &x);
      |                  ~~~~~^~~~~~~~~~~~
clo.cpp:40:68: note: in expansion of macro 'input'
   40 |  for (ll i=n; i<n+m; ++i) {input(orders[i].c); input(orders[i].f); input(orders[i].v); orders[i].c=-orders[i].c; }
      |                                                                    ^~~~~
#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...