Language: C++

# ?¢?????????°
??°????????????$v_{i}$????????????$w_{i}$???$N$???????????\????????????$W$????????????????±????
1. ?????????????????????????°?????????????
2. ????????????????????????????¶????$W$???
## ?????\
?¬¬1????????\2?????´??°$N$???$W$?????¨?????????????????\?????\$N$????????\?¬¬$i$??????????????????$v_{i}$?????????$w_{i}$???????????????????????????????????°????????´??¨???????????????
## ??????
?????????????????§??????????????????
## ?????¶
$1\leqslant N\leqslant 100$
$1\leqslant v_{i}\leqslant 1000$
$1\leqslant w_{i}\leqslant 1000$
$1\leqslant W\leqslant 10000$
# ?§£?¢???????
|??°?????????|??´???|
|---|---|
|items[N+1]|?????´??°??????item[m].v???item[i].w????????°????¬¬i???????????????????????????|
|C[N+1][W+1]|?????´??°??????C[i][w]??¨??????i??????????£???\?????????W???????????¶?????????????????§???|

$C[i][w]=max(C[i-1][w-w_{i}]+v_{i},C[i-1][w])$

???????¬¬????????????????¶??????????????????????$i$?????????????¶????$w$???

# ??£???

```c++
#include <iostream>
#include <algorithm>
#include <vector>
#define NMAX 105
#define WMAX 10005
#define DIAGONAL 1
#define TOP 0

using namespace std;

struct Item
{
	int value,weight;
};

int N,W;
Item items[NMAX+1];
int C[NMAX+1][WMAX+1],G[NMAX+1][WMAX+1];

void compute(int &maxValue, vector<int> &selection)
{
    //????????§?°?w???0?????????????????°i???0??¶?????????????????????0?????????C???w=0???i=0????????????????´??????¨??¨????§???????0.
	for(int w=0;w<=W;w++)
	{
		C[0][w]=0;
		// G[0][w]=DIAGONAL;//????????????
	}
	
	for(int i=1;i<=N;i++)
		C[i][0]=0;
	
	for(int i=1;i<=N;i++)
	{
		for(int w=1;w<=W;w++)
		{
			C[i][w]=C[i-1][w];
			G[i][w]=TOP;
			if(items[i].weight>w)
				continue;
			if(items[i].value+C[i-1][w-items[i].weight]>C[i-1][w])
			{
				C[i][w]=items[i].value+C[i-1][w-items[i].weight];
				G[i][w]=DIAGONAL;
			}
		}
	}
	maxValue=C[N][W];
	selection.clear();
	for(int i=N,w=W;i>=1;i--)
	{
		if(G[i][w]==DIAGONAL)
		{
			selection.push_back(items[i].value);
			w-=items[i].weight;
		}
	}
	reverse(selection.begin(), selection.end());
}

void input()
{
	cin>>N>>W;
	for(int i=1;i<=N;i++)
		cin>>items[i].value>>items[i].weight;
}

int main()
{
	int maxValue;
	vector<int> selection;
	input();
	compute(maxValue,selection);
	
	cout<<maxValue<<endl;
	
	/*cout<<endl;
	for(int n=0;n<=N;n++)
	{
		for(int m=0;m<=W;m++)
		cout<<G[n][m]<<" ";
		cout<<endl;
	}*/
	/*cout<<"??????????????????????????????";
	for(int i=0;i<selection.size();i++)cout<<selection[i]<<" ";*/
}
```

Compiler output:
a.cc:1:3: error: invalid preprocessing directive #?
    1 | # ?¢?????????°
      |   ^
a.cc:1:4: error: extended character ¢ is not valid in an identifier
    1 | # ?¢?????????°
      |    ^
a.cc:1:14: error: extended character ° is not valid in an identifier
    1 | # ?¢?????????°
      |              ^
a.cc:2:3: error: extended character ° is not valid in an identifier
    2 | ??°????????????$v_{i}$????????????$w_{i}$???$N$???????????\????????????$W$????????????????±????
      |   ^
a.cc:2:59: error: stray '\' in program
    2 | ??°????????????$v_{i}$????????????$w_{i}$???$N$???????????\????????????$W$????????????????±????
      |                                                           ^
a.cc:2:91: error: extended character ± is not valid in an identifier
    2 | ??°????????????$v_{i}$????????????$w_{i}$???$N$???????????\????????????$W$????????????????±????
      |                                                                                           ^
a.cc:3:29: error: extended character ° is not valid in an identifier
    3 | 1. ?????????????????????????°?????????????
      |                             ^
a.cc:4:32: error: extended character ¶ is not valid in an identifier
    4 | 2. ????????????????????????????¶????$W$???
      |                                ^
a.cc:5:1: error: stray '##' in program
    5 | ## ?????\
      | ^~
a.cc:6:2: error: extended character ¬ is not valid in an identifier
    6 | ?¬¬1????????\2?????´??°$N$???$W$?????¨?????????????????\?????\$N$????????\?¬¬$i$??????????????????$v_{i}$?????????$w_{i}$???????????????????????????????????°????????´??¨???????????????
      |  ^
a.cc:6:2: error: extended character ¬ is not valid in an identifier
a.cc:6:13: error: stray '\' in program
    6 | ?¬¬1????????\2?????´??°$N$???$W$?????¨?????????????????\?????\$N$????????\?¬¬$i$??????????????????$v_{i}$?????????$w_{i}$???????????????????????????????????°????????´??¨???????????????
      |             ^
a.cc:6:23: error: extended character ° is not valid in an identifier
    6 | ?¬¬1????????\2?????´??°$N$???$W$?????¨?????????????????\?????\$N$????????\?¬¬$i$??????????????????$v_{i}$?????????$w_{i}$???????????????????????????????????°????????´??¨???????????????
      |                       ^
a.cc:6:56: error: stray '\' in program
    6 | ?¬¬1????????\2?????´??°$N$???$W$?????¨?????????????????\?????\$N$????????\?¬¬$i$??????????????????$v_{i}$?????????$w_{i}$???????????????????????????????????°????????´??¨???????????????
      |                                                        ^
a.cc:6:62: error: stray '\' in program
    6 | ?¬¬1????????\2?????´??°$N$???$W$?????¨?????????????????\?????\$N$????????\?¬¬$i$??????????????????$v_{i}$?????????$w_{i}$???????????????????????????????????°????????´??¨???????????????
      |                                                              ^
a.cc:6:74: error: stray '\' in program
    6 | ?¬¬1????????\2?????´??°$N$???$W$?????¨?????????????????\?????\$N$????????\?¬¬$i$??????????????????$v_{i}$?????????$w_{i}$???????????????????????????????????°????????´??¨???????????????
      |                                                                          ^
a.cc:6:76: error: extended character ¬ is not valid in an identifier
    6 | ?¬¬1????????\2?????´??°$N$???$W$?????¨?????????????????\?????\$N$????????\?¬¬$i$??????????????????$v_{i}$?????????$w_{i}$???????????????????????????????????°????????´??¨???????????????
      |                                                                            ^
a.cc:6:76: error: extended character ¬ is not valid in an identifier
a.cc:6:157: error: extended character ° is not valid in an identifier
    6 | ?¬¬1????????\2?????´??°$N$???$W$?????¨?????????????????\?????\$N$????????\?¬¬$i$??????????????????$v_{i}$?????????$w_{i}$???????????????????????????????????°????????´??¨???????????????
      |                                                                                                                                                             ^
a.cc:7:1: error: stray '##' in program
    7 | ## ??????
      | ^~
a.cc:8:18: error: extended character § is not valid in an identifier
    8 | ?????????????????§??????????????????
      |                  ^
a.cc:9:1: error: stray '##' in program
    9 | ## ?????¶
      | ^~
a.cc:9:9: error: extended character ¶ is not valid in an identifier
    9 | ## ?????¶
      |         ^
a.cc:10:3: error: stray '\' in program
   10 | $1\leqslant N\leqslant 100$
      |   ^
a.cc:10:14: error: stray '\' in program
   10 | $1\leqslant N\leqslant 100$
      |              ^
a.cc:11:3: error: stray '\' in program
   11 | $1\leqslant v_{i}\leqslant 1000$
      |   ^
a.cc:11:18: error: stray '\' in program
   11 | $1\leqslant v_{i}\leqslant 1000$
      |                  ^
a.cc:12:3: error: stray '\' in program
   12 | $1\leqslant w_{i}\leqslant 1000$
      |   ^
a.cc:12:18: error: stray '\' in program
   12 | $1\leqslant w_{i}\leqslant 1000$
      |                  ^
a.cc:13:3: error: stray '\' in program
   13 | $1\leqslant W\leqslant 10000$
      |   ^
a.cc:13:14: error: stray '\' in program
   13 | $1\leqslant W\leqslant 10000$
      |              ^
a.cc:14:3: error: invalid preprocessing directive #?
   14 | # ?§£?¢???????
      |   ^
a.cc:14:4: error: extended character § is not valid in an identifier
   14 | # ?§£?¢???????
      |    ^
a.cc:14:4: error: extended character £ is not valid in an identifier
a.cc:14:7: error: extended character ¢ is not valid in an identifier
   14 | # ?§£?¢???????
      |       ^
a.cc:15:4: error: extended character ° is not valid in an identifier
   15 | |??°?????????|??´???|
      |    ^
a.cc:17:21: error: extended character ° is not valid in an identifier
   17 | |items[N+1]|?????´??°??????item[m].v???item[i].w????????°????¬¬i???????????????????????????|
      |                     ^
a.cc:17:57: error: extended character ° is not valid in an identifier
   17 | |items[N+1]|?????´??°??????item[m].v???item[i].w????????°????¬¬i???????????????????????????|
      |                                                         ^
a.cc:17:62: error: extended character ¬ is not valid in an identifier
   17 | |items[N+1]|?????´??°??????item[m].v???item[i].w????????°????¬¬i???????????????????????????|
      |                                                              ^
a.cc:17:62: error: extended character ¬ is not valid in an identifier
a.cc:18:22: error: extended character ° is not valid in an identifier
   18 | |C[N+1][W+1]|?????´??°??????C[i][w]??¨??????i??????????£???\?????????W???????????¶?????????????????§???|
      |                      ^
a.cc:18:56: error: extended character £ is not valid in an identifier
   18 | |C[N+1][W+1]|?????´??°??????C[i][w]??¨??????i??????????£???\?????????W???????????¶?????????????????§???|
      |                                                        ^
a.cc:18:60: error: stray '\' in program
   18 | |C[N+1][W+1]|?????´??°??????C[i][w]??¨??????i??????????£???\?????????W???????????¶?????????????????§???|
      |                                                            ^
a.cc:18:82: error: extended character ¶ is not valid in an identifier
   18 | |C[N+1][W+1]|?????´??°??????C[i][w]??¨??????i??????????£???\?????????W???????????¶?????????????????§???|
      |                                                                                  ^
a.cc:18:100: error: extended character § is not valid in an identifier
   18 | |C[N+1][W+1]|?????´??°??????C[i][w]??¨??????i??????????£???\?????????W???????????¶?????????????????§???|
      |                                                                                                    ^
a.cc:22:8: error: extended character ¬ is not valid in an identifier
   22 | ???????¬¬????????????????¶??????????????????????$i$?????????????¶????$w$???
      |        ^
a.cc:22:8: error: extended character ¬ is not valid in an identifier
a.cc:22:26: error: extended character ¶ is not valid in an identifier
   22 | ???????¬¬????????????????¶??????????????????????$i$?????????????¶????$w$???
      |                          ^
a.cc:22:65: error: extended character ¶ is not valid in an identifier
   22 | ???????¬¬????????????????¶??????????????????????$i$?????????????¶????$w$???
      |                                                                 ^
a.cc:24:3: error: invalid preprocessing directive #?
   24 | # ??£???
      |   ^
a.cc:24:5: error: extended character £ is not valid in an identifier
   24 | # ??£???
      |     ^
a.cc:26:1: error: stray '`' in program
   26 | ```c++
      | ^
a.cc:26:2: error: stray '`' in program
   26 | ```c++
      |  ^
a.cc:26:3: error: stray '`' in program
   26 | ```c++
      |   ^
a.cc:112:1: error: stray '`' in program
  112 | ```
      | ^
a.cc:112:2: error: stray '`' in program
  112 | ```
      |  ^
a.cc:112:3: error: stray '`' in program
  112 | ```
      |   ^
a.cc:2:1: error: expected unqualified-id before '?' token
    2 | ??°????????????$v_{i}$????????????$w_{i}$???$N$???????????\????????????$W$????????????????±????
      | ^
a.cc:2:22: error: '$' does not name a type
    2 | ??°????????????$v_{i}$????????????$w_{i}$???$N$???????????\????????????$W$????????????????±????
      |                      ^
a.cc:2:41: error: '$' does not name a type
    2 | ??°????????????$v_{i}$????????????$w_{i}$???$N$???????????\????????????$W$????????????????±????
      |                                         ^
a.cc:6:105: error: '$' does not name a type
    6 | ?¬¬1????????\2?????´??°$N$???$W$?????¨?????????????????\?????\$N$????????\?¬¬$i$??????????????????$v_{i}$?????????$w_{i}$???????????????????????????????????°????????´??¨???????????????
      |                                                                                                         ^
a.cc:6:121: error: '$' does not name a type
    6 | ?¬¬1????????\2?????´??°$N$???$W$?????¨?????????????????\?????\$N$????????\?¬¬$i$??????????????????$v_{i}$?????????$w_{i}$???????????????????????????????????°????????´??¨???????????????
      |