제출 #471002

#제출 시각아이디문제언어결과실행 시간메모리
471002Shogun3103Knapsack (NOI18_knapsack)C++17
0 / 100
1 ms716 KiB
#include <bits/stdc++.h> using namespace std; void setIO(string fileName = ""){ if(fileName.length()){ freopen((fileName+".in").c_str(), "r", stdin); freopen((fileName+".out").c_str(), "w", stdout); } } #define ll long long #define ld long double #define FOR(i,a,b) for(__typeof(b) i=a; i<=b; i++) #define FOD(i,a,b) for(__typeof(b) i=b; i>=a; i--) #define EACH(u, v) for(auto& u : v) #define sz(x) ((int)(x).size()) #define all(x) (x).begin(), (x).end() #define pb push_back #define ii pair<int,int> #define iii pair<int,ii> #define ld2 pair<ld, ld> #define ll2 pair<ll, ll> #define X first #define Y second #define ed "\n" #define sp " " const int oo1 = 1e9 + 7; const int oo2 = 1e9 + 9; const int N = 1e5 + 1; const int M = 5e6 + 1; struct Data { int v, w, k; }; Data a[N]; int s, n; ll dp[N][2001]; void solve() { cin >> s >> n; FOR(i, 1, n) cin >> a[i].v >> a[i].w >> a[i].k; FOR(i, 1, n) { FOR(j, 0, s) { if(j - a[i].w >= 0) dp[i][j] = max(dp[i][j], dp[i-1][j-a[i].w] + a[i].v); else dp[i][j] = dp[i-1][j]; } } cout << dp[n][s]; } int main() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); setIO(""); int t; t = 1; //cin >> t; FOR(i, 1, t) { solve(); } return 0; }

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

knapsack.cpp: In function 'void setIO(std::string)':
knapsack.cpp:7:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |         freopen((fileName+".in").c_str(), "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
knapsack.cpp:8:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |         freopen((fileName+".out").c_str(), "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...