diff --git a/S2OJ/9/9.cpp b/S2OJ/9/9.cpp new file mode 100644 index 00000000..3c6bd586 --- /dev/null +++ b/S2OJ/9/9.cpp @@ -0,0 +1,30 @@ +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +const int N = 20005; + +int s, n, a[N], f[N]; + +int main() { + std::ios::sync_with_stdio(false); + cin.tie(nullptr); + + cin >> s >> n; + + for (int i = 1; i <= n; i++) { + cin >> a[i]; + } + + for (int i = 1; i <= n; i++) { + for (int j = s; j >= a[i]; j--) { + f[j] = std::max(f[j], f[j - a[i]] + a[i]); + } + } + + cout << s - f[s] << endl; + + return 0; +} diff --git a/S2OJ/9/data/ex_land1.in b/S2OJ/9/data/ex_land1.in new file mode 100644 index 00000000..c83a2544 --- /dev/null +++ b/S2OJ/9/data/ex_land1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ed321f9ab87e3c04967fa82339968cbe2c63489151a88a38780b61477bad2433 +size 18 diff --git a/S2OJ/9/data/ex_land1.out b/S2OJ/9/data/ex_land1.out new file mode 100644 index 00000000..804fcc90 --- /dev/null +++ b/S2OJ/9/data/ex_land1.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9a271f2a916b0b6ee6cecb2426f0b3206ef074578be55d9bc94f6f3fe3ab86aa +size 2 diff --git a/S2OJ/9/data/land1.in b/S2OJ/9/data/land1.in new file mode 100644 index 00000000..23fb5f8a --- /dev/null +++ b/S2OJ/9/data/land1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dcbd5eeecc108f62479b0670050a35f39638ecc2f4ad8627b959f090458df457 +size 31 diff --git a/S2OJ/9/data/land1.out b/S2OJ/9/data/land1.out new file mode 100644 index 00000000..60f093fb --- /dev/null +++ b/S2OJ/9/data/land1.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a9742eb8ee320e006666aef25ae9aeed948247f3125c9cafa7cf97b7e7467dd5 +size 3 diff --git a/S2OJ/9/data/land2.in b/S2OJ/9/data/land2.in new file mode 100644 index 00000000..d37e65e7 --- /dev/null +++ b/S2OJ/9/data/land2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:633e66c4b7c2eade19c761667a3f28ac5575fad98a7027f7e8b585d8f7f54512 +size 53 diff --git a/S2OJ/9/data/land2.out b/S2OJ/9/data/land2.out new file mode 100644 index 00000000..1afab5f7 --- /dev/null +++ b/S2OJ/9/data/land2.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4355a46b19d348dc2f57c046f8ef63d4538ebb936000f3c9ee954a27460dd865 +size 2 diff --git a/S2OJ/9/data/land3.in b/S2OJ/9/data/land3.in new file mode 100644 index 00000000..61e4b583 --- /dev/null +++ b/S2OJ/9/data/land3.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:70d9b4703d10610e092362da11b359f225302e3e83ff61bfdae275f2f957de39 +size 64 diff --git a/S2OJ/9/data/land3.out b/S2OJ/9/data/land3.out new file mode 100644 index 00000000..1afab5f7 --- /dev/null +++ b/S2OJ/9/data/land3.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4355a46b19d348dc2f57c046f8ef63d4538ebb936000f3c9ee954a27460dd865 +size 2 diff --git a/S2OJ/9/data/land4.in b/S2OJ/9/data/land4.in new file mode 100644 index 00000000..9972c447 --- /dev/null +++ b/S2OJ/9/data/land4.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7c9a71753bb6e144128457f3e5e959e69b86237dc7c0e40cdecc373f4b6c5b37 +size 150 diff --git a/S2OJ/9/data/land4.out b/S2OJ/9/data/land4.out new file mode 100644 index 00000000..cb90f684 --- /dev/null +++ b/S2OJ/9/data/land4.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:06e9d52c1720fca412803e3b07c4b228ff113e303f4c7ab94665319d832bbfb7 +size 2 diff --git a/S2OJ/9/data/land5.in b/S2OJ/9/data/land5.in new file mode 100644 index 00000000..fce7cd4f --- /dev/null +++ b/S2OJ/9/data/land5.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8e8766cbe0e8228b78482f83acdbf9fefdf274edb9540ca69d7fdcbe57be5384 +size 11 diff --git a/S2OJ/9/data/land5.out b/S2OJ/9/data/land5.out new file mode 100644 index 00000000..1afab5f7 --- /dev/null +++ b/S2OJ/9/data/land5.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4355a46b19d348dc2f57c046f8ef63d4538ebb936000f3c9ee954a27460dd865 +size 2 diff --git a/S2OJ/9/data/problem.conf b/S2OJ/9/data/problem.conf new file mode 100644 index 00000000..708cdd9c --- /dev/null +++ b/S2OJ/9/data/problem.conf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:707af40625cb114cbf9e185c9f5f96b8a6b9cbc70678a47a1ad37bc6642170c3 +size 192