Submission #880218

#TimeUsernameProblemLanguageResultExecution timeMemory
880218cpptowinKnapsack (NOI18_knapsack)C++17
12 / 100
0 ms468 KiB
#include<bits/stdc++.h> #define fo(i,d,c) for(int i=d;i<=c;i++) #define fod(i,c,d) for(int i=c;i>=d;i--) #define maxn 1000010 #define N 1010 #define fi first #define se second #define pb emplace_back #define en cout<<"\n"; #define int long long #define inf 1000000000 #define pii pair<int,int> #define vii vector<pii> #define lb(x) x&-x #define bit(i,j) ((i>>j)&1) #define offbit(i,j) (i^(1<<j)) #define onbit(i,j) (i|(1<<j)) #define vi vector<int> template <typename T1, typename T2> bool minimize(T1 &a, T2 b){if (a > b) {a = b; return true;} return false;} template <typename T1, typename T2> bool maximize(T1 &a, T2 b){if (a < b) {a = b; return true;} return false;} using namespace std; struct things { int v,w,k; }a[maxn]; int n,s; namespace sub1 { void solve() { cout << min(s / a[1].w,a[1].k) * a[1].v; } } main() { #define name "TASK" if(fopen(name".inp","r")) { freopen(name".inp","r",stdin); freopen(name".out","w",stdout); } ios_base::sync_with_stdio(false);cin.tie(NULL); cin >> s >> n; fo(i,1,n) cin >> a[i].v >> a[i].w >> a[i].k; if(n == 1) sub1::solve(); }

Compilation message (stderr)

knapsack.cpp:34:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   34 | main()
      | ^~~~
knapsack.cpp: In function 'int main()':
knapsack.cpp:39:15: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |        freopen(name".inp","r",stdin);
      |        ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
knapsack.cpp:40:15: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |        freopen(name".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...