제출 #1114000

#제출 시각아이디문제언어결과실행 시간메모리
1114000ntdaccodeCloud Computing (CEOI18_clo)C++17
100 / 100
230 ms1532 KiB
#include<bits/stdc++.h>
#define fori(i,a,b) for(int i = a;i <= b; i++)
#define int long long

using namespace std;

typedef pair<int,int> ii;
typedef tuple<int,int,int> tp;

const int M = 1e5 + 10;
const int N = 2e3 + 10;
const int mod = 1e9 + 7;

int n , m ;
struct node
{
  int c,f,v;
}buy[N],sell[N];

bool cmp(const node & a, const node & b) {
  return a.f < b.f;
}

int f[M];
int kq = 0;
int32_t main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  if(fopen("1.inp","r"))
  {
    freopen("1.inp","r",stdin);
    freopen("1.out","w",stdout);
  }
  #define task ""
  if(fopen(task".inp","r"))
  {
    freopen(task".inp","r",stdin);
    freopen(task".out","w",stdout);
  }
  cin >> n ;
  for(int i = 1;i <= n ; i++) cin >> buy[i].c >> buy[i].f >> buy[i].v;
  cin >> m;
  for(int i = 1;i <= m ; i++) cin >> sell[i].c >> sell[i].f >> sell[i].v;
  sort(buy + 1, buy + n + 1,cmp);
  sort(sell + 1,sell + m + 1,cmp);
  for(int i = 1;i <= 100000; i++) f[i] = -1e15;
  int j = n ,sum = 0;
  for(int i = m;i != 0; i--) {

    while(sell[i].f <= buy[j].f && j != 0) {
        sum += buy[j].c;
      for(int e = sum ; e >= buy[j].c ; e--) {
          f[e] = max(f[e],f[e - buy[j].c] - buy[j].v);
      }
      j--;
    }
    //cout << i << " " << j << "\n";
      for(int e = sell[i].c;e <= sum; e++) {
        f[e - sell[i].c] = max(f[e - sell[i].c],f[e] + sell[i].v);
        kq = max(f[e - sell[i].c],kq);
      }
  }
  cout << kq;
}

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

clo.cpp: In function 'int32_t main()':
clo.cpp:33:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |     freopen("1.inp","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~
clo.cpp:34:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |     freopen("1.out","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~
clo.cpp:39:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |     freopen(task".inp","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
clo.cpp:40:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |     freopen(task".out","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#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...