Submission #1092407

#TimeUsernameProblemLanguageResultExecution timeMemory
1092407iloveroseanneKnapsack (NOI18_knapsack)C++14
49 / 100
567 ms262144 KiB
/// PARK CHAEYOUNG IS MY LOVE /// Author: Ngo Ba Van /// roses_are_rosie #include<bits/stdc++.h> using namespace std; #define ll long long #define int ll #define fi first #define se second #define MASK(i) (1LL<<i) #define BIT(x,i) (x&MASK(i)) #define ONBIT(x,i) (x|MASK(i)) #define OFFBIT(x,i) (x&~MASK(i)) #define COUNT(x) (__builtin_popcount(x)) #define RVAN1102 signed main() using ii=pair<int,int>; const ll N=1e5+5,M=1e9+7; ll n,m,res; map<ll,ll>dp[2005]; vector<ii>b; struct cmp { ll x,y,z; }a[N]; void phantich(int id,ll n) { int c=0; while (n-MASK(c)>0) { b.push_back({a[id].x*MASK(c),a[id].y*MASK(c)}); n-=MASK(c); c++; } if (n>0) b.push_back({a[id].x*n,a[id].y*n}); } void nhap() { b.push_back({0,0}); cin>>n>>m; for (int i=1;i<=m;i++) cin>>a[i].x>>a[i].y>>a[i].z, phantich(i,a[i].z); /// for (int j=0;j<=n;j++) for (int i=1;i<b.size();i++) { dp[j][i]=dp[j][i-1]; if (j-b[i].se>=0) dp[j][i]=max(dp[j][i-1],dp[j-b[i].se][i-1]+b[i].fi); } cout<<dp[n][b.size()-1]; } RVAN1102 { ios_base::sync_with_stdio(false); cin.tie(NULL); #define task "" #define task "a" if(fopen(task".inp","r")) { freopen(task".inp","r",stdin); freopen(task".out","w",stdout); } int t=1; //cin>>t; while (t--) nhap(); }

Compilation message (stderr)

knapsack.cpp:57: warning: "task" redefined
   57 | #define task "a"
      | 
knapsack.cpp:56: note: this is the location of the previous definition
   56 | #define task ""
      | 
knapsack.cpp: In function 'void nhap()':
knapsack.cpp:45:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |     for (int i=1;i<b.size();i++)
      |                  ~^~~~~~~~~
knapsack.cpp: In function 'int main()':
knapsack.cpp:60:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   60 |     freopen(task".inp","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
knapsack.cpp:61:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   61 |     freopen(task".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...