Submission #730620

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
7306202023-04-26 07:59:09PVSekharKnapsack (NOI18_knapsack)C++14
100 / 100
124 ms5320 KiB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD = 1000000007;
int main()
{
ll n,s;
cin>>s>>n;
vector<ll> dp(s+1,0);
vector<vector<pair<ll,ll>>> store(s+1);
ll v,w,k;
for (ll i = 0; i < n; i++)
{
cin>>v>>w>>k;
store[w].push_back({v,k});
}
for (auto &st:store)
{
sort(st.begin(),st.end());
reverse(st.begin(),st.end());
}
vector<pair<ll,ll>> final_store;
ll ind=0,x=0;
for (ll i = 1; i <= s; i++)
{
ind=0;
for (ll j = 0; j <= (s/i); j++)
{
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

knapsack.cpp: In function 'int main()':
knapsack.cpp:31:20: 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]
   31 |             if(ind >= store[i].size()) break;
      |                ~~~~^~~~~~~~~~~~~~~~~~
knapsack.cpp:25:14: warning: unused variable 'x' [-Wunused-variable]
   25 |     ll ind=0,x=0;
      |              ^
#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...