# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1041204 | Antony2357111317 | Knapsack (NOI18_knapsack) | C++11 | 89 ms | 5572 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
struct item {
ll weight, worth, cnt;
};
bool comp(item i1, item i2){
if(i1.weight == i2.weight){
return (i1.worth > i2.worth);
}
return (i1.weight < i2.weight);
}
int main() {
ll S, N;
cin >> S >> N;
vector<item> items;
for(ll i = 0; i < N; i++){
ll wei, wor, cnt;
cin >> wor >> wei >> cnt;
items.push_back({wei, wor, cnt});
}
sort(items.begin(), items.end(), comp);
vector<item> new_item;
map<ll,ll> myMap;
for(item item: items){
if(myMap[item.weight] * item.weight > S){
continue;
}
myMap[item.weight] += item.cnt;
new_item.push_back(item);
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |