CARVIEW |
Select Language
HTTP/2 200
date: Sun, 12 Oct 2025 03:45:28 GMT
content-type: text/html; charset=UTF-8
server: cloudflare
x-frame-options: DENY
x-content-type-options: nosniff
x-xss-protection: 1;mode=block
vary: accept-encoding
cf-cache-status: DYNAMIC
content-encoding: gzip
set-cookie: _csrf-frontend=8c8536e63c1e500c89f5ad2dcfcf0dd56c49e3045a52ee06946217229fadde43a%3A2%3A%7Bi%3A0%3Bs%3A14%3A%22_csrf-frontend%22%3Bi%3A1%3Bs%3A32%3A%22Wvuhfm4bYSFEhG3oZn6gND0jhpGX96GZ%22%3B%7D; HttpOnly; Path=/
cf-ray: 98d39ac599eec1ba-BLR
Knapsack_FPTAS.awk - Pastebin.com
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## format of input
- ## first line; K (capacity of bin) , k (divider)
- ## for each line
- ## weight value
- NR == 1 {
- K = $1;
- k = $2;
- for (j = 1;j <= K;j++) {
- dp [ j , 0 ] = 0;
- }
- }
- NR != 1 {
- i = NR - 1;
- w = $1 / k;
- v = $2;
- # dp[weight][item]
- dp[ 0 , i ] = 0;
- for (j = 1;j <= K;j++) {
- if (j - w > 0) {
- dp [ j , i ] = max( dp [ j , i - 1 ], dp [ j - w , i - 1 ] + v );
- } else {
- dp [ j , i ] = dp [ j , i - 1 ];
- }
- }
- }
- END {
- printf "result : %d\n" , dp [ K , NR - 1 ];
- }
- function max (a,b) {
- if (a > b) {
- return a;
- } else {
- return b;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
-
⭐⭐⭐Instant Profit Method⭐⭐
Java | 25 sec ago | 0.10 KB
-
⭐⭐⭐MAKE $500 IN 15 MIN⭐⭐
Java | 38 sec ago | 0.10 KB
-
⭐⭐⭐MAKE $500 IN 15 MIN⭐⭐
Java | 1 min ago | 0.10 KB
-
⭐⭐⭐Instant Profit Method⭐⭐
Java | 1 min ago | 0.10 KB
-
⭐⭐⭐Make $15OO in 2O minutesV G⭐⭐
Java | 1 min ago | 0.10 KB
-
⭐✅ Exploit 2500$ in 15 Minutes⭐⭐⭐ G
JavaScript | 1 min ago | 0.25 KB
-
⭐⭐⭐Crypto Accounts⭐⭐
Java | 1 min ago | 0.10 KB
-
Free Crypto Method (NEVER SEEN BEFORE)⭐⭐ X
JavaScript | 2 min ago | 0.25 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand