QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#692098 | #7619. Make SYSU Great Again I | jacob02 | Compile Error | / | / | C++20 | 1.4kb | 2024-10-31 13:48:38 | 2024-10-31 13:48:38 |
Judging History
answer
#include<iostream>
#include<vector>
#define ll long long
using namespace std;
int n, w;
int a[500005];
int num[15];
int maxn;
int dp[15][500005];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> w;
for (int i = 1; i <= n; i++) {
cin >> a[i];
num[a[i]]++;
maxn = max(maxn, a[i]);
}
int cnt = 0;
vector<int> nn;
nn.push_back(0);
for (int i = 1; i <= maxn; i++) {
if (num[i])nn.push_back(num[i]);
}
int ans = 0;
maxn = nn.size() - 1;
// cout<<maxn<<"?";
while (cnt <= maxn) {
ans++;
int now = maxn - cnt;
memset(dp, 0, sizeof(dp));
for (int i = 1; i <= now; i++) {
for (int j = w; j >= 1; j--) {
if (j >= nn[i]) {
dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - nn[i]] + 1);
}
else {
dp[i][j] = dp[i - 1][j];
}
}
}
int j = w;
vector<int> tp;
for (int i = now; i >= 1; i--) {
if (dp[i][j] != dp[i - 1][j]) {
tp.push_back(i);
j = j - nn[i];
}
}
for (int i = 0; i < tp.size(); i++) {
nn.erase(nn.begin() + tp[i], nn.begin() + tp[i] + 1);
}
cnt += tp.size();
}
cout << ans << "\n";
return 0;
}
Details
answer.code: In function ‘int main()’: answer.code:32:9: error: ‘memset’ was not declared in this scope 32 | memset(dp, 0, sizeof(dp)); | ^~~~~~ answer.code:3:1: note: ‘memset’ is defined in header ‘<cstring>’; did you forget to ‘#include <cstring>’? 2 | #include<vector> +++ |+#include <cstring> 3 | #define ll long long