Submission #1273253

#TimeUsernameProblemLanguageResultExecution timeMemory
1273253arkanefuryKnapsack (NOI18_knapsack)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#define pb push_back
#define S second
#define F first
#define FOR(x, n, m, d) for(int x = n; x <= m; x += d)
#define FORR(x, n, m, d) for(int x = n; x >= m; x -= d)
#define nikita ios_base::sync_with_stdio(0), cin.tie(0);
#define int long long
using namespace std;
const int N = 2050;
int n, cost, weight, number, m, ans;
int dp[N], dp1[N][N], x, y;
vector<pair<int, int>>g[N];
vector<int>v[N];
signed main(){
	cin >> m >> n;
	FOR(i, 1, n,1 ){
		cin >> cost >> weight >> number;
		if(weight <= m)g[weight].pb({cost, number});
	}
	FOR(i, 1, m, 1)sort(g[i].rbegin(), g[i].rend());
	FOR(i, 1, m, 1){
		for(auto j : g[i]){
			while(j.S != 0 && v[i].size() < m/i)v[i].pb(j.F), j.S --;
		}
	}
	FOR(i, 1, m, 1)reverse(all(v[i]));
	ans = 0;
	FOR(i, 1, m, 1){
		dp[i] = -1e18;
		y=-1;
		FORR(j, i-1, 0, 1){
			x = i-j;
			if(dp[i] < dp[j])dp[i] = dp[j], y = j;
			if(v[x].size() >= 1 + dp1[j][x] && dp[i] < dp[j] + v[x][ v[x].size() - 1 - dp1[j][x] ]){
				dp[i] = dp[j] + v[x][ v[x].size() - 1 - dp1[j][x] ];
				y = j;
			}
		}
		if(y==-1)continue;
		FOR(j, 1, m, 1)dp1[i][j] += dp1[y][j];
		dp1[i][i-y] ++;
		ans = max(ans, dp[i]);
	}
	cout << ans;
}

Compilation message (stderr)

knapsack.cpp: In function 'int main()':
knapsack.cpp:27:32: error: 'all' was not declared in this scope; did you mean 'std::filesystem::perms::all'?
   27 |         FOR(i, 1, m, 1)reverse(all(v[i]));
      |                                ^~~
      |                                std::filesystem::perms::all
In file included from /usr/include/c++/13/filesystem:48,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:200,
                 from knapsack.cpp:1:
/usr/include/c++/13/bits/fs_fwd.h:154:7: note: 'std::filesystem::perms::all' declared here
  154 |       all               =  0777,
      |       ^~~