/ WOJ /

记录详情

System Error


  
Testdata configuration incorrect.
Memory limit larger than memory_max

代码

#include <bits/extc++.h>
#define endl '\n'
typedef long long ll;
#define int ll
using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

void Main() {
  int n, w, res = 0;
  cin >> n >> w;
  vector<int> dp(w + 1);
  for (int i = 1; i <= n; ++i) {
    int v, c, m;
    cin >> v >> c >> m;// w v c
    if (!c) {
      res += v * m;
      continue;
    }
    int k = w / c;
    m = min(m, k);
    for (int d = 0; d < c; ++d) {
      deque<int> q1, q2;
      k = (w - d) / c;
      for (int j = 0; j <= k; ++j) {
        while (!q2.empty() && dp[d + j * c] - j * v >= q2.back()) {
          q2.pop_back();
          q1.pop_back();
        }
        q1.push_back(j);
        q2.push_back(dp[d + j * c] - j * v);
        while (!q1.empty() && q1[0] < j - m) {
          q1.pop_front();
          q2.pop_front();
        }
        dp[d + j * c] = max(dp[d + j * c], q2[0] + j * v);
      }
    }
  }
  cout << res + dp[w] << endl;
}

// #define __CP_MULTI_TEST_CASES

signed main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int t = 1;
#ifdef __CP_MULTI_TEST_CASES
  cin >> t;
#endif
  while (t--) {
    Main();
  }
  return 0;
}

信息

递交者
类型
递交
题目
P1000 云剪贴板
题目数据
下载
语言
C++
递交时间
2025-06-21 13:19:41
评测时间
2025-06-21 19:47:41
评测机
分数
0
总耗时
0ms
峰值内存
0 Bytes