제출 #724018

#제출 시각아이디문제언어결과실행 시간메모리
724018ivazivaKnapsack (NOI18_knapsack)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define MAXN 100010 #define MAXM 2010 long long n; long long s; vector<priority_queue<pair<long long,long long>>> niz[MAXN]; vector<pair<long long,pair<long long,long long>>> pomoc; long long dp[MAXM]; int main() { ios_base::sync_with_stdio(false); ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin>>s>>n; for (long long i=1;i<=n;i++) { long long x,y,z; cin>>x>>y>>z; niz[y].push({x,z}); } for (long long i=1;i<=s;i++) { long long ans=s/i; while (ans and niz[i].empty()==false) { pair<long long,long long> p=niz[i].top; niz[i].pop(); long long v=p.first; long long k=p.second; for (long long j=1;j<=min(ans,k);j++) pomoc.push_back({v,{i,k}}); ans-=min(ans,k); } } for (long long i=1;i<=s;i++) { dp[i]=dp[i-1]; for (long long j=0;j<pomoc.size();j++) { if (i>=pomoc[j].second.first) dp[[i]=max(dp[i],dp[i-pomoc[j].second.first]+pomoc[j].first); } } long long sol=0; for (long long i=1;i<=s;i++) sol=max(sol,dp[i]); cout<<sol<<endl; }

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

knapsack.cpp: In function 'int main()':
knapsack.cpp:25:16: error: 'class std::vector<std::priority_queue<std::pair<long long int, long long int> > >' has no member named 'push'
   25 |         niz[y].push({x,z});
      |                ^~~~
knapsack.cpp:32:48: error: 'class std::vector<std::priority_queue<std::pair<long long int, long long int> > >' has no member named 'top'
   32 |             pair<long long,long long> p=niz[i].top;
      |                                                ^~~
knapsack.cpp:33:20: error: 'class std::vector<std::priority_queue<std::pair<long long int, long long int> > >' has no member named 'pop'
   33 |             niz[i].pop();
      |                    ^~~
knapsack.cpp:43:29: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |         for (long long j=0;j<pomoc.size();j++)
      |                            ~^~~~~~~~~~~~~
knapsack.cpp:45:45: error: two consecutive '[' shall only introduce an attribute before '[' token
   45 |             if (i>=pomoc[j].second.first) dp[[i]=max(dp[i],dp[i-pomoc[j].second.first]+pomoc[j].first);
      |                                             ^