Submission #10405744


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
int n, w;
long long sol[100010];

int main() {
    cin >> n >> w;

    for (int i = 1; i <= n; i++) {
        int weight, value;
        cin >> weight >> value;

        for (int j = w - weight; j >= 0; j--)
            sol[j + weight] = max(sol[j + weight], sol[j] + value);
    }

    cout << sol[w];
    return 0;
}



Submission Info

Submission Time
Task D - Knapsack 1
User CosminMorar
Language C++14 (GCC 5.4.1)
Score 100
Code Size 390 Byte
Status AC
Exec Time 18 ms
Memory 1024 KB

Judge Result

Set Name All
Score / Max Score 100 / 100
Status
AC × 13
Set Name Test Cases
All 0_00, 0_01, 0_02, 1_00, 1_01, 1_02, 1_03, 1_04, 1_05, 1_06, 1_07, 1_08, 1_09
Case Name Status Exec Time Memory
0_00 AC 1 ms 256 KB
0_01 AC 1 ms 256 KB
0_02 AC 1 ms 256 KB
1_00 AC 1 ms 256 KB
1_01 AC 18 ms 1024 KB
1_02 AC 10 ms 1024 KB
1_03 AC 13 ms 1024 KB
1_04 AC 15 ms 1024 KB
1_05 AC 16 ms 1024 KB
1_06 AC 17 ms 1024 KB
1_07 AC 17 ms 1024 KB
1_08 AC 17 ms 1024 KB
1_09 AC 18 ms 1024 KB