buggy_code
stringlengths
11
625k
fixed_code
stringlengths
17
625k
bug_type
stringlengths
2
4.45k
language
int64
0
8
token_count
int64
5
200k
change_count
int64
0
100
#include <bits/stdc++.h> using namespace std; #define EPS 1e-10 struct Point { double x, y; Point() {} Point(double x, double y) : x(x), y(y) {} Point operator-(const Point &p) const { return Point(x - p.x, y - p.y); } }; double dot(const Point &a, const Point &b) { return a.x * b.x + a.y * b.y; } double ...
#include <bits/stdc++.h> using namespace std; #define EPS 1e-10 struct Point { double x, y; Point() {} Point(double x, double y) : x(x), y(y) {} Point operator-(const Point &p) const { return Point(x - p.x, y - p.y); } }; double dot(const Point &a, const Point &b) { return a.x * b.x + a.y * b.y; } double ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22]]
1
426
4
#include <algorithm> #include <cassert> #include <complex> #include <cstdio> #include <iostream> #include <map> #include <vector> using namespace std; #define REP(i, n) for (int i = 0; i < (int)(n); ++i) #define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i) #define ALL(c) (c).begin(), (c).end() #define SIZE(v) ((...
#include <algorithm> #include <cassert> #include <complex> #include <cstdio> #include <iostream> #include <map> #include <vector> using namespace std; #define REP(i, n) for (int i = 0; i < (int)(n); ++i) #define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i) #define ALL(c) (c).begin(), (c).end() #define SIZE(v) ((...
[["-", 0, 1, 0, 2, 3, 4, 0, 25, 0, 35], ["+", 0, 14, 8, 9, 0, 14, 8, 9, 0, 45], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 79], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 14, 8, 9, 0, 46]]
1
1,720
7
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <iostream> #include <map> #include <set> #include <string> #include <utility> #include <vector> #define loop(i, a, b) for (int i = a; i < b; i++) #define rep(i, a) loop(i, 0, a) #define pb push_back #define mp make_pair #define it ::ite...
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <iostream> #include <map> #include <set> #include <string> #include <utility> #include <vector> #define loop(i, a, b) for (int i = a; i < b; i++) #define rep(i, a) loop(i, 0, a) #define pb push_back #define mp make_pair #define it ::ite...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
1,254
4
#include <algorithm> #include <cassert> #include <cmath> #include <iomanip> #include <iostream> #include <vector> using namespace std; template <class T> ostream &operator<<(ostream &os, const vector<T> &vs) { if (vs.empty()) return os << "[]"; os << "[" << vs[0]; for (int i = 1; i < vs.size(); i++) os ...
#include <algorithm> #include <cassert> #include <cmath> #include <iomanip> #include <iostream> #include <vector> using namespace std; template <class T> ostream &operator<<(ostream &os, const vector<T> &vs) { if (vs.empty()) return os << "[]"; os << "[" << vs[0]; for (int i = 1; i < vs.size(); i++) os ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 79], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
661
4
#include <bits/stdc++.h> using namespace std; namespace arithmetic { template <typename T> class Addition { public: template <typename V> T operator+(const V &v) const { return T(static_cast<const T &>(*this)) += v; } }; template <typename T> class Subtraction { public: template <typename V> T operator-(co...
#include <bits/stdc++.h> using namespace std; namespace arithmetic { template <typename T> class Addition { public: template <typename V> T operator+(const V &v) const { return T(static_cast<const T &>(*this)) += v; } }; template <typename T> class Subtraction { public: template <typename V> T operator-(co...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 79], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22]]
1
2,336
4
#include <bits/stdc++.h> using namespace std; typedef complex<double> P; typedef vector<P> vec; double eps = 1e-7; bool eq(double a, double b) { return (b - a < eps && a - b < eps); } double dot(P a, P b) { return real(b * conj(a)); } double cross(P a, P b) { return imag(b * conj(a)); } P project(P a, P b, P c) { b ...
#include <bits/stdc++.h> using namespace std; typedef complex<double> P; typedef vector<P> vec; double eps = 1e-7; bool eq(double a, double b) { return (b - a < eps && a - b < eps); } double dot(P a, P b) { return real(b * conj(a)); } double cross(P a, P b) { return imag(b * conj(a)); } P project(P a, P b, P c) { b ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 79], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
760
4
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using ull = unsigned long long; using uint = unsigned int; using vi = vector<int>; using vb = vector<bool>; using vd = vector<double>; using vl = vector<ll>; using vvi = vector<vi>; using vvb = vector<vb>; using vvd = vector<vd...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using ull = unsigned long long; using uint = unsigned int; using vi = vector<int>; using vb = vector<bool>; using vd = vector<double>; using vl = vector<ll>; using vvi = vector<vi>; using vvb = vector<vb>; using vvd = vector<vd...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 79], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
580
4
#define _USE_MATH_DEFINES #include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <cmath> #include <cstdio> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <limits> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #in...
#define _USE_MATH_DEFINES #include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <cmath> #include <cstdio> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <limits> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #in...
[["-", 0, 7, 8, 57, 15, 339, 51, 16, 17, 19], ["-", 0, 7, 8, 57, 15, 339, 51, 16, 12, 22], ["+", 0, 7, 8, 57, 15, 339, 51, 16, 17, 60], ["+", 0, 7, 8, 57, 15, 339, 51, 16, 12, 22]]
1
2,079
4
#include <bits/stdc++.h> using namespace std; #define int long long // <-----!!!!!!!!!!!!!!!!!!! #define rep(i, n) for (int i = 0; i < (n); i++) #define rep2(i, a, b) for (int i = (a); i < (b); i++) #define rrep(i, n) for (int i = (n)-1; i >= 0; i--) #define rrep2(i, a, b) for (int i = (b)-1; i >= (a); i--) #define al...
#include <bits/stdc++.h> using namespace std; #define int long long // <-----!!!!!!!!!!!!!!!!!!! #define rep(i, n) for (int i = 0; i < (n); i++) #define rep2(i, a, b) for (int i = (a); i < (b); i++) #define rrep(i, n) for (int i = (n)-1; i >= 0; i--) #define rrep2(i, a, b) for (int i = (b)-1; i >= (a); i--) #define al...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
493
4
#include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <queue> #include <stack> #include <string> #include <vector> using namespace std; const int INF = INT_MAX / 3; #define REP(i, n) for (int i = 0; i < (int)n; i++) #define FOR(i, c) ...
#include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <queue> #include <stack> #include <string> #include <vector> using namespace std; const int INF = INT_MAX / 3; #define REP(i, n) for (int i = 0; i < (int)n; i++) #define FOR(i, c) ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18]]
1
541
6
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef double R; // double long double ??????????????? // cmath?????¢??°??????????????????????????????????????????????????§???????????? typedef complex<R> Point; typedef pair<Point, Point> Line; typedef pai...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef double R; // double long double ??????????????? // cmath?????¢??°??????????????????????????????????????????????????§???????????? typedef complex<R> Point; typedef pair<Point, Point> Line; typedef pai...
[["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 106], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 60], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
1
1,996
4
#include <bits/stdc++.h> using namespace std; #ifdef DEBUG_MODE #define DBG(n) n; #else #define DBG(n) ; #endif #define REP(i, n) for (ll(i) = (0); (i) < (n); ++i) #define rep(i, s, g) for (ll(i) = (s); (i) < (g); ++i) #define rrep(i, s, g) for (ll(i) = (s); i >= (g); --(i)) #define PB push_back #define MP make_pair ...
#include <bits/stdc++.h> using namespace std; #ifdef DEBUG_MODE #define DBG(n) n; #else #define DBG(n) ; #endif #define REP(i, n) for (ll(i) = (0); (i) < (n); ++i) #define rep(i, s, g) for (ll(i) = (s); (i) < (g); ++i) #define rrep(i, s, g) for (ll(i) = (s); i >= (g); --(i)) #define PB push_back #define MP make_pair ...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 79], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 98], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 79], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17,...
1
2,486
8
#include <algorithm> #include <cassert> #include <cctype> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <stri...
#include <algorithm> #include <cassert> #include <cctype> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <stri...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 79], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
2,835
4
#include <bits/stdc++.h> using namespace std; #define dump(n) cout << "# " << #n << '=' << (n) << endl #define repi(i, a, b) for (int i = int(a); i < int(b); i++) #define peri(i, a, b) for (int i = int(b); i-- > int(a);) #define rep(i, n) repi(i, 0, n) #define per(i, n) peri(i, 0, n) #define all(c) begin(c), end(c) #d...
#include <bits/stdc++.h> using namespace std; #define dump(n) cout << "# " << #n << '=' << (n) << endl #define repi(i, a, b) for (int i = int(a); i < int(b); i++) #define peri(i, a, b) for (int i = int(b); i-- > int(a);) #define rep(i, n) repi(i, 0, n) #define per(i, n) peri(i, 0, n) #define all(c) begin(c), end(c) #d...
[["-", 8, 9, 0, 1, 0, 11, 12, 16, 17, 20], ["-", 8, 9, 0, 1, 0, 11, 12, 16, 12, 13], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 79], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 13]]
1
954
4
n = int(input()) points = [complex(*map(int, input().split())) for _ in range(n)] edges = [p1 - p0 for p0, p1 in zip(points, points[1:] + [points[0]])] prev = edges[0] while edges: edge = edges.pop() if edge.real * prev.imag - prev.real * edge.imag < 1e-6: print(0) break prev = edge else: ...
n = int(input()) points = [complex(*map(int, input().split())) for _ in range(n)] edges = [p1 - p0 for p0, p1 in zip(points, points[1:] + [points[0]])] prev = edges[0] while edges: edge = edges.pop() if edge.real * prev.imag - prev.real * edge.imag < -1e-6: print(0) break prev = edge else: ...
[["+", 8, 196, 0, 57, 15, 666, 0, 664, 17, 33]]
5
113
1
n = eval(input()) p = [list(map(int, input().split())) for i in range(n)] for i in range(n): x1 = p[i-1][0] - p[i-2][0] y1 = p[i-1][1] - p[i-2][1] x2 = p[i][0] - p[i-2][0] y2 = p[i][0] - p[i-2][1] if x1*y2 - y1*x2 < 0: print(0) break else: print(1)
n = eval(input()) p = [list(map(int, input().split())) for i in range(n)] for i in range(n): x1 = p[i-1][0] - p[i-2][0] y1 = p[i-1][1] - p[i-2][1] x2 = p[i][0] - p[i-2][0] y2 = p[i][1] - p[i-2][1] if x1*y2 - y1*x2 < 0: print(0) break else: print(1)
[["-", 0, 1, 0, 662, 12, 657, 31, 206, 206, 612], ["+", 0, 1, 0, 662, 12, 657, 31, 206, 206, 612]]
5
144
2
n = int(input()) S = float(0) x = [] y = [] for _ in range(n): xi,yi = list(map(float, input().split())) x.append(xi) y.append(yi) result = True for i in range(n): ax = x[(i+1) % n] - x[i % n] ay = y[(i+1) % n] - y[i % n] bx = x[(i+2) % n] - x[(i+1) % n] by = y[(i+2) % n] - y[(i+1) % n] outer = (ax * by...
n = int(input()) S = float(0) x = [] y = [] for _ in range(n): xi,yi = list(map(float, input().split())) x.append(xi) y.append(yi) result = True for i in range(n): ax = x[(i+1) % n] - x[i % n] ay = y[(i+1) % n] - y[i % n] bx = x[(i+2) % n] - x[(i+1) % n] by = y[(i+2) % n] - y[(i+1) % n] outer = (ax * by...
[["-", 0, 7, 8, 196, 0, 57, 15, 666, 667, 19], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 18]]
5
193
2
import java.io.*; import java.lang.*; import java.util.*; public class Main { static int INF = 1000000000; static int MAXN = 31; public static void main(String[] args) { Scanner input = new Scanner(System.in); int n = input.nextInt(); int[][] point = new int[n][2]; for (int i = 0; i < n; ++i) {...
import java.io.*; import java.lang.*; import java.util.*; public class Main { static int INF = 1000000000; static int MAXN = 31; public static void main(String[] args) { Scanner input = new Scanner(System.in); int n = input.nextInt(); int[][] point = new int[n][2]; for (int i = 0; i < n; ++i) {...
[["-", 8, 196, 0, 37, 0, 16, 31, 16, 12, 22], ["+", 8, 196, 0, 37, 0, 16, 31, 16, 12, 22], ["-", 8, 196, 0, 37, 0, 16, 12, 16, 12, 22], ["+", 8, 196, 0, 37, 0, 16, 12, 16, 12, 22]]
3
453
4
#include <bits/stdc++.h> #define rep(i, n) for (int i = 1, i##_end_ = (n); i <= i##_end_; ++i) using namespace std; typedef pair<int, int> pii; typedef long long ll; const double eps = 1e-10; int sgn(double x) { if (fabs(x) < eps) return 0; return x < 0 ? -1 : 1; } struct Point { double x, y; Point(double ...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 1, i##_end_ = (n); i <= i##_end_; ++i) using namespace std; typedef pair<int, int> pii; typedef long long ll; const double eps = 1e-10; int sgn(double x) { if (fabs(x) < eps) return 0; return x < 0 ? -1 : 1; } struct Point { double x, y; Point(double ...
[["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 106], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 60], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22]]
1
2,158
4
#include <bits/stdc++.h> #define _overload(_1, _2, _3, name, ...) name #define _rep(i, n) _range(i, 0, n) #define _range(i, a, b) for (int i = int(a); i < int(b); ++i) #define rep(...) _overload(__VA_ARGS__, _range, _rep, )(__VA_ARGS__) #define _rrep(i, n) _rrange(i, n, 0) #define _rrange(i, a, b) for (int i = int(a)...
#include <bits/stdc++.h> #define _overload(_1, _2, _3, name, ...) name #define _rep(i, n) _range(i, 0, n) #define _range(i, a, b) for (int i = int(a); i < int(b); ++i) #define rep(...) _overload(__VA_ARGS__, _range, _rep, )(__VA_ARGS__) #define _rrep(i, n) _rrange(i, n, 0) #define _rrange(i, a, b) for (int i = int(a)...
[["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 18], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 19]]
1
1,527
2
import math def dot(a, b): return a.real * b.real + a.imag * b.imag def projection(p0,p1,p2): a=p1-p0 b=p2-p0 pro = a * dot(a, b) / (abs(a) ** 2) t=p0+pro return t def get_cross_point(p0,p1,p2): pro=projection(p0,p1,p2) e =(p1-p0)/abs(p1-p0) base = (r**2 - abs(pro-p2)**2)**0.5 if pro-e*base.real ...
import math def dot(a, b): return a.real * b.real + a.imag * b.imag def projection(p0,p1,p2): a=p1-p0 b=p2-p0 pro = a * dot(a, b) / (abs(a) ** 2) t=p0+pro return t def get_cross_point(p0,p1,p2): pro=projection(p0,p1,p2) e =(p1-p0)/abs(p1-p0) base = (r**2 - abs(pro-p2)**2)**0.5 if (pro-e*base).rea...
[["+", 0, 57, 15, 666, 0, 319, 500, 23, 0, 24], ["+", 0, 57, 15, 666, 0, 319, 500, 23, 0, 25]]
5
356
4
def solve_eq(a,b,c): return (-b-(b**2-4*a*c)**0.5)/2*a,(-b+(b**2-4*a*c)**0.5)/2*a def ret_line(x1,y1,x2,y2): k = (y1-y2)/(x1-x2) d = y1-k*x1 return k,d x,y,r = map(float,input().split()) q = int(input()) x1,y1,x2,y2 = [],[],[],[] for i in range(q): arr = list(map(float,input().split())) x1...
def solve_eq(a,b,c): return (-b-(b**2-4*a*c)**0.5)/(2*a),(-b+(b**2-4*a*c)**0.5)/(2*a) def ret_line(x1,y1,x2,y2): k = (y1-y2)/(x1-x2) d = y1-k*x1 return k,d x,y,r = map(float,input().split()) q = int(input()) x1,y1,x2,y2 = [],[],[],[] for i in range(q): arr = list(map(float,input().split())) ...
[["+", 0, 37, 0, 432, 0, 657, 12, 23, 0, 24], ["+", 0, 37, 0, 432, 0, 657, 12, 23, 0, 25], ["-", 3, 4, 0, 657, 31, 657, 12, 657, 12, 22], ["+", 3, 4, 0, 657, 31, 657, 12, 657, 12, 22]]
5
370
6
from math import sqrt cx,cy,r = map(int,input().split()) c = [cx, cy] q = int(input()) class Line:pass def dot(a, b): return sum([i * j for i,j in zip(a, b)]) def add(a,b): return [a[0] + b[0],a[1] + b[1]] def sub(a, b): return [a[0] - b[0],a[1] - b[1]] def multi(k, a): return [k*a[0],k*a[1]] def cros...
from math import sqrt cx,cy,r = map(int,input().split()) c = [cx, cy] q = int(input()) class Line:pass def dot(a, b): return sum([i * j for i,j in zip(a, b)]) def add(a,b): return [a[0] + b[0],a[1] + b[1]] def sub(a, b): return [a[0] - b[0],a[1] - b[1]] def multi(k, a): return [k*a[0],k*a[1]] def cros...
[["+", 0, 658, 8, 652, 3, 4, 0, 652, 63, 22], ["+", 8, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["+", 8, 652, 3, 4, 0, 652, 3, 4, 0, 21], ["+", 8, 652, 3, 4, 0, 652, 3, 4, 0, 612], ["+", 8, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
465
5
#include <math.h> #include <stdio.h> int cpcc(int p0[2], int r0, int p1[2], int r1, double s[2], double t[2]) { int x1 = p1[0] - p0[0], y1 = p1[1] - p0[1], sx = y1, sy = -x1; long long a = x1 * x1 + y1 * y1, b = r0 * r0 - r1 * r1 + a; double c = sqrt(a), d = b / (2 * c), e = sqrt(r0 * r0 - b * b / (4 * a)); if ...
#include <math.h> #include <stdio.h> int cpcc(int p0[2], int r0, int p1[2], int r1, double s[2], double t[2]) { int x1 = p1[0] - p0[0], y1 = p1[1] - p0[1], sx = y1, sy = -x1; long long a = x1 * x1 + y1 * y1, b = r0 * r0 - r1 * r1 + a; double c = sqrt(a), d = b / (2 * c), e = sqrt(r0 * r0 - b * b / (4.0 * a)); i...
[["-", 0, 16, 12, 16, 12, 23, 0, 16, 31, 13], ["+", 0, 16, 12, 16, 12, 23, 0, 16, 31, 13]]
0
457
2
#include <bits/stdc++.h> using namespace std; typedef long long int64; typedef pair<int, int> pii; typedef vector<int> vi; typedef complex<double> point; struct circle { point p; double r; }; struct line { point p, q; }; const double eps = 1e-9; double sign(double x) { return x < -eps ? -1 : x > eps; } circl...
#include <bits/stdc++.h> using namespace std; typedef long long int64; typedef pair<int, int> pii; typedef vector<int> vi; typedef complex<double> point; struct circle { point p; double r; }; struct line { point p, q; }; const double eps = 1e-9; double sign(double x) { return x < -eps ? -1 : x > eps; } circl...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 338, 8, 1, 0, 16, 17, 151], ["+", 0, 338, 8, 1, 0, 16, 12, 5, 0, 62], ["+", 0, 338, 8, 1, 0, 16, 12, 5, 0, 6]]
1
493
6
#include <algorithm> #include <array> #include <cassert> #include <cmath> #include <iomanip> #include <iostream> using Number = double; const Number EPS = 1e-10; const Number INF = 1e10; const Number PI = acos(-1.0); inline int sign(Number x) { return (x < -EPS) ? -1 : (x > EPS) ? +1 : 0; } inline bool equal(Number ...
#include <algorithm> #include <array> #include <cassert> #include <cmath> #include <iomanip> #include <iostream> using Number = double; const Number EPS = 1e-10; const Number INF = 1e10; const Number PI = acos(-1.0); inline int sign(Number x) { return (x < -EPS) ? -1 : (x > EPS) ? +1 : 0; } inline bool equal(Number ...
[["-", 0, 43, 49, 50, 51, 16, 12, 16, 12, 13], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 0, 21], ["+", 49, 50, 51, 16, 12, 16, 31, 16, 12, 22], ["+", 0, 43, 49, 50, 51, 16, 12, 16, 17, 85], ["+", 0, 43, 49, 50, 51, 16, 12, 16, 12, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 0, 35], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78]]
1
2,482
7
#include <cmath> #include <iomanip> #include <iostream> using namespace std; int main() { double c1x = 0, c1y = 0, c1r = 0, c2x = 0, c2y = 0, c2r = 0; cin >> c1x >> c1y >> c1r >> c2x >> c2y >> c2r; double a = 0, b = 0, s = 0, t = 0, u = 0, v1 = 0, v2 = 0, w1 = 0, w2 = 0; if (c1y == c2y) { b = (c1x + c2x...
#include <cmath> #include <iomanip> #include <iostream> using namespace std; int main() { double c1x = 0, c1y = 0, c1r = 0, c2x = 0, c2y = 0, c2r = 0; cin >> c1x >> c1y >> c1r >> c2x >> c2y >> c2r; double a = 0, b = 0, s = 0, t = 0, u = 0, v1 = 0, v2 = 0, w1 = 0, w2 = 0; if (c1y == c2y) { b = (c1x + c2x...
[["-", 0, 16, 12, 16, 12, 23, 0, 16, 31, 22], ["-", 0, 16, 12, 16, 12, 23, 0, 16, 17, 33], ["+", 0, 16, 12, 16, 12, 23, 0, 16, 17, 33], ["+", 0, 16, 12, 16, 12, 23, 0, 16, 12, 22]]
1
376
4
c1x, c1y, c1r = map(int, input().split()) c2x, c2y, c2r = map(int, input().split()) dx, dy = c2x - c1x, c2y - c1y s2 = dx ** 2 + dy ** 2 a = (s2 + c1r ** 2 - c2r ** 2) / 2 df = (s2 * c1r ** 2 - a ** 2) ** 0.5 ix1, ix2 = (a * dx + dy * df) / s2, (a * dx - dy * df) / s2 iy1, iy2 = (a * dy - dx * df) / s2, (a * dy + dx * ...
c1x, c1y, c1r = map(int, input().split()) c2x, c2y, c2r = map(int, input().split()) dx, dy = c2x - c1x, c2y - c1y s2 = dx ** 2 + dy ** 2 a = (s2 + c1r ** 2 - c2r ** 2) / 2 df = (s2 * c1r ** 2 - a ** 2) ** 0.5 ix1, ix2 = (a * dx + dy * df) / s2, (a * dx - dy * df) / s2 iy1, iy2 = (a * dy - dx * df) / s2, (a * dy + dx * ...
[["-", 0, 1, 0, 652, 3, 4, 0, 657, 12, 22], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 22]]
5
185
2
#include <bits/stdc++.h> #define ll long long #define INF 1000000005 #define MOD 1000000007 #define EPS 1e-10 #define rep(i, n) for (int i = 0; i < n; ++i) using namespace std; typedef complex<double> C; namespace std { bool operator<(const C &a, const C &b) { return real(a) != real(b) ? real(a) < real(b) : imag(a...
#include <bits/stdc++.h> #define ll long long #define INF 1000000005 #define MOD 1000000007 #define EPS 1e-10 #define rep(i, n) for (int i = 0; i < n; ++i) using namespace std; typedef complex<double> C; namespace std { bool operator<(const C &a, const C &b) { return real(a) != real(b) ? real(a) < real(b) : imag(a...
[["-", 51, 2, 3, 4, 0, 2, 3, 4, 0, 22], ["+", 51, 2, 3, 4, 0, 2, 3, 4, 0, 22], ["-", 0, 43, 49, 50, 51, 2, 3, 4, 0, 22], ["+", 0, 43, 49, 50, 51, 2, 3, 4, 0, 22]]
1
3,220
10
lines = $stdin.read array = lines.split("\n") INF = 1 << 25 def coin(amount,kind,coins) dp = Array.new(amount+1, INF) dp[0] = 0 for i in 1...kind for j in coins[i]...amount dp[j] = [dp[j], dp[j - coins[i]] + 1].min end end dp end N,M = array[0].split(" ").map(&:to_i) coins = array[1].split(" ...
lines = $stdin.read array = lines.split("\n") INF = 1 << 25 def coin(amount,kind,coins) dp = Array.new(amount+1, INF) dp[0] = 0 for i in 0...kind for j in coins[i]..amount dp[j] = [dp[j], dp[j - coins[i]] + 1].min end end dp end N,M = array[0].split(" ").map(&:to_i) coins = array[1].split(" "...
[["-", 8, 736, 0, 88, 51, 267, 0, 475, 756, 612], ["+", 8, 736, 0, 88, 51, 267, 0, 475, 756, 612], ["-", 8, 170, 0, 88, 51, 267, 0, 475, 17, 389], ["+", 8, 170, 0, 88, 51, 267, 0, 475, 17, 757], ["-", 0, 652, 3, 4, 0, 742, 0, 738, 17, 33], ["-", 0, 652, 3, 4, 0, 742, 0, 738, 12, 612]]
4
148
6
def solution(n, m, coins) dp = [0] + [Float::INFINITY] * n for coin in coins for amount in 0..n if amount >= coin dp[amount] = [dp[amount], dp[amount - coin] + 1].min else dp[amount] = dp[amount] end end p dp end dp[n] end first_line = gets.split.map(&:to_i) coin...
def solution(n, m, coins) dp = [0] + [Float::INFINITY] * n for coin in coins for amount in 0..n if amount >= coin dp[amount] = [dp[amount], dp[amount - coin] + 1].min else dp[amount] = dp[amount] end end end dp[n] end first_line = gets.split.map(&:to_i) coins = gets.s...
[["-", 8, 736, 0, 88, 8, 170, 0, 652, 735, 22], ["-", 0, 88, 8, 170, 0, 652, 3, 4, 0, 22]]
4
115
2
n, m = list(map(int, input().split())) c = list(map(int, input().split())) t = [float('inf') for i in range(n+1)] t[0] = 0 for i in range(n): if c[i] > n: break else: for j in range(c[i], n+1): t[j] = min([t[j], t[j-c[i]]+1]) print(t[n])
n, m = list(map(int, input().split())) c = list(map(int, input().split())) t = [float('inf') for i in range(n+1)] t[0] = 0 for i in range(m): if c[i] > n: break else: for j in range(c[i], n+1): t[j] = min([t[j], t[j-c[i]]+1]) print(t[n])
[["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 22], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 22]]
5
128
2
n,m = map(int,input().split()) c = list(map(int,input().split())) minimum = [50000] * (n+1) minimum[0] = 0 for i in range(1,n+1): if c[j] <= 2: continue for j in range(m): if c[j]<=i and minimum[i-c[j]] + 1 < minimum[i]: minimum[i] = minimum[i-c[j]]+1 print(minimum[n])
n,m = map(int,input().split()) c = list(map(int,input().split())) minimum = [50000] * (n+1) minimum[0] = 0 for i in range(1,n+1): if minimum[i] <= 1: continue for j in range(m): if c[j]<=i and minimum[i-c[j]] + 1 < minimum[i]: minimum[i] = minimum[i-c[j]]+1 print(minimum[n])
[["-", 8, 196, 0, 57, 15, 666, 0, 206, 51, 22], ["+", 8, 196, 0, 57, 15, 666, 0, 206, 51, 22], ["-", 8, 196, 0, 57, 15, 666, 0, 206, 206, 22], ["+", 8, 196, 0, 57, 15, 666, 0, 206, 206, 22], ["-", 0, 7, 8, 196, 0, 57, 15, 666, 0, 612], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 0, 612]]
5
127
6
n,m = map(int, input().split()) d = list(map(int, input().split())) inf = float('inf') dp = [inf for i in range(n+1)] dp[0] = 0 for i in range(m): print(dp) for j in range(d[i], n+1): dp[j] = min(dp[j], dp[j-d[i]]+1) print(dp[-1])
n,m = map(int, input().split()) d = list(map(int, input().split())) inf = float('inf') dp = [inf for i in range(n+1)] dp[0] = 0 for i in range(m): for j in range(d[i], n+1): dp[j] = min(dp[j], dp[j-d[i]]+1) print(dp[-1])
[["-", 0, 7, 8, 196, 0, 1, 0, 652, 63, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
5
120
4
package main import ( "bufio" "fmt" "io" "log" "os" "sort" "strconv" ) var pri = fmt.Println var scan = fmt.Fscanln var scanone = fmt.Fscan func main() { if os.Getenv("DEBUG") != "" { fname := "input.txt" f, err := os.Open(fname) if err != nil { log.Fatal(err) } r := bufio.NewReader(f) for { ...
package main import ( "bufio" "fmt" "io" "log" "os" "sort" "strconv" ) var pri = fmt.Println var scan = fmt.Fscanln var scanone = fmt.Fscan func main() { if os.Getenv("DEBUG") != "" { fname := "input.txt" f, err := os.Open(fname) if err != nil { log.Fatal(err) } r := bufio.NewReader(f) for { ...
[["-", 12, 432, 0, 2, 3, 4, 0, 446, 0, 447], ["-", 12, 432, 0, 2, 3, 4, 0, 446, 448, 78]]
7
525
2
import java.io.*; import java.util.Arrays; import java.util.StringTokenizer; class Main { static final PrintWriter out = new PrintWriter(System.out); static final int INF = Integer.MAX_VALUE / 2; public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStr...
import java.io.*; import java.util.Arrays; import java.util.StringTokenizer; class Main { static final PrintWriter out = new PrintWriter(System.out); static final int INF = Integer.MAX_VALUE / 2; public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStr...
[["-", 0, 57, 75, 1, 0, 11, 12, 492, 141, 22], ["+", 0, 57, 75, 1, 0, 11, 12, 492, 141, 22]]
3
381
2
#include <algorithm> #include <iostream> using namespace std; int main() { int n, m, c[20], dp[50001], i = 0, j = 0; cin >> n >> m; for (i; i < m; i++) { cin >> c[i]; } sort(c, c + m); for (i = 0; i <= n; i++) { dp[i] = 100000; } dp[0] = 0; for (i = 0; i < m; i++) { dp[c[i]] = 1; } fo...
#include <algorithm> #include <iostream> using namespace std; int main() { int n, m, c[20], dp[50001], i = 0, j = 0; cin >> n >> m; for (i; i < m; i++) { cin >> c[i]; } sort(c, c + m); for (i = 0; i <= n; i++) { dp[i] = 100000; } dp[0] = 0; for (i = 0; i < m; i++) { dp[c[i]] = 1; } fo...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 0, 11, 12, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 11, 12, 2, 3, 4, 0, 16, 12, 13]]
1
201
4
#include <algorithm> #include <functional> #include <iostream> #include <vector> #define F first #define S second using namespace std; typedef pair<int, int> P; const int INF = 1 << 30; int main() { int n, m; int coin[20], dp[50001] = {}; fill(dp, dp + 50001, INF); cin >> n >> m; for (int i = 0; i < m; i++) {...
#include <algorithm> #include <functional> #include <iostream> #include <vector> #define F first #define S second using namespace std; typedef pair<int, int> P; const int INF = 1 << 30; int main() { int n, m; int coin[20], dp[50001] = {}; fill(dp, dp + 50001, INF); cin >> n >> m; for (int i = 0; i < m; i++) {...
[["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 47], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13]]
1
198
2
#include <bits/stdc++.h> using namespace std; const int MAXV = 50005; int coin[20], dp[MAXV]; int main() { int N, M; scanf("%d%d", &N, &M); for (int i = 0; i < N; i++) scanf("%d", &coin[i]); memset(dp, -1, sizeof(dp)); dp[0] = 0; for (int i = 0; i < M; i++) { for (int x = coin[i]; x <= N; x++...
#include <bits/stdc++.h> using namespace std; const int MAXV = 50005; int coin[20], dp[MAXV]; int main() { int N, M; scanf("%d%d", &N, &M); for (int i = 0; i < N; i++) scanf("%d", &coin[i]); memset(dp, -1, sizeof(dp)); dp[0] = 0; for (int i = 0; i < M; i++) { for (int x = coin[i]; x <= N; x++...
[["-", 12, 16, 31, 69, 341, 342, 0, 16, 17, 72], ["+", 12, 16, 31, 69, 341, 342, 0, 16, 17, 33]]
1
218
2
#include <climits> #include <cmath> #include <iomanip> #include <iostream> using namespace std; int dp[50001]; // j?????????????°?????????°????????? int main() { int n, m; cin >> n >> m; int d[m]; for (int i = 0; i < m; i++) { cin >> d[i]; } for (int i = 0; i <= n; i++) { dp[i] = INT_MAX; } ...
#include <climits> #include <cmath> #include <iomanip> #include <iostream> using namespace std; int dp[50001]; // j?????????????°?????????°????????? int main() { int n, m; cin >> n >> m; int d[m]; for (int i = 0; i < m; i++) { cin >> d[i]; } for (int i = 0; i <= n; i++) { dp[i] = INT_MAX; } ...
[["-", 0, 7, 8, 9, 0, 7, 15, 16, 31, 22], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 31, 22], ["-", 0, 7, 8, 9, 0, 7, 26, 27, 28, 22], ["+", 0, 7, 8, 9, 0, 7, 26, 27, 28, 22], ["+", 51, 16, 31, 69, 341, 342, 0, 16, 17, 33], ["+", 51, 16, 31, 69, 341, 342, 0, 16, 12, 22]]
1
182
6
#include <algorithm> #include <iostream> #include <vector> using namespace std; int ans[50001] = {}; int main() { int i, j, k, n, m, c; cin >> n >> m; for (i = 0; i < m; i++) { cin >> c; for (j = 1; j + c <= n; j++) { if (ans[j + c] == 0) ans[j + c] = ans[j] + 1; else ans[j ...
#include <algorithm> #include <iostream> #include <vector> using namespace std; int ans[50001] = {}; int main() { int i, j, k, n, m, c; cin >> n >> m; for (i = 0; i < m; i++) { cin >> c; for (j = 0; j + c <= n; j++) { if (ans[j + c] == 0) ans[j + c] = ans[j] + 1; else ans[j ...
[["-", 0, 7, 8, 9, 0, 7, 10, 11, 12, 13], ["+", 0, 7, 8, 9, 0, 7, 10, 11, 12, 13]]
1
142
2
#include <algorithm> #include <iostream> using namespace std; static const int INFTY = 50000; int main() { int n, m; cin >> n >> m; int T[n + 1], C[m]; for (int i = 1; i <= n; i++) { T[i] = INFTY; } T[0] = 0; for (int i = 1; i <= m; i++) { cin >> C[m]; } for (int i = 1; i <= m; i++) { ...
#include <algorithm> #include <iostream> using namespace std; static const int INFTY = 50000; int main() { int n, m; cin >> n >> m; int T[n + 1], C[m + 1]; for (int i = 1; i <= n; i++) { T[i] = INFTY; } T[0] = 0; for (int i = 1; i <= m; i++) { cin >> C[i]; } for (int i = 1; i <= m; i++) { ...
[["+", 8, 9, 0, 43, 49, 80, 81, 16, 17, 72], ["+", 8, 9, 0, 43, 49, 80, 81, 16, 12, 13], ["-", 0, 1, 0, 16, 12, 69, 341, 342, 0, 22], ["+", 0, 1, 0, 16, 12, 69, 341, 342, 0, 22]]
1
179
4
#include <algorithm> #include <iostream> using namespace std; int main() { int n, m; cin >> n >> m; int c[21]; int t[50000]; int ini = (1 << 29); for (int i = 1; i <= m; i++) { cin >> c[i]; } t[0] = 0; for (int i = 1; i < 50000; i++) { t[i] = ini; } for (int i = 1; i <= m; i++) { for ...
#include <algorithm> #include <iostream> using namespace std; int main() { int n, m; cin >> n >> m; int c[21]; int t[50001]; int ini = (1 << 29); for (int i = 1; i <= m; i++) { cin >> c[i]; } t[0] = 0; for (int i = 1; i <= 50000; i++) { t[i] = ini; } for (int i = 1; i <= m; i++) { for...
[["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 17, 19]]
1
178
6
#include <bits/stdc++.h> using namespace std; int main() { int dp[50001]; int n, m; cin >> n >> m; int c[m + 1]; for (int i = 1; i <= m; i++) cin >> c[i]; dp[0] = 0; for (int i = 1; i <= n; ++i) { dp[i] = -1; } for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { if (i - c...
#include <bits/stdc++.h> using namespace std; int main() { int dp[50001]; int n, m; cin >> n >> m; int c[m + 1]; for (int i = 1; i <= m; i++) cin >> c[i]; dp[0] = 0; for (int i = 1; i <= n; ++i) { dp[i] = -1; } for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { if (i - c...
[["-", 0, 1, 0, 16, 31, 16, 12, 69, 28, 22], ["+", 0, 1, 0, 16, 31, 16, 12, 69, 28, 22]]
1
213
2
#include <algorithm> #include <stdio.h> int dp[50001]; const int INF = 114514; int main() { int n, m; scanf("%d %d", &n, &m); int c[m]; for (int j = 0; j < m; j++) { scanf("%d\n", &c[j]); } // initialize dp table dp[0] = 0; for (int i = 1; i <= n; i++) { dp[i] = INF; } for (int l = 0; l <...
#include <algorithm> #include <stdio.h> int dp[50001]; const int INF = 114514; int main() { int n, m; scanf("%d %d", &n, &m); int c[m]; for (int j = 0; j < m; j++) { scanf("%d\n", &c[j]); } // initialize dp table dp[0] = 0; for (int i = 1; i <= n; i++) { dp[i] = INF; } for (int l = 0; l <...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18]]
1
185
2
#include <iostream> using namespace std; int main() { int n = 0, m = 0, c = 0, a[500001] = {}; cin >> n >> m; for (int i = 1; i <= n; i++) { a[i] = i; } for (int i = 0; i < m; i++) { cin >> c; a[c] = 1; } for (int i = 1; i <= n; i++) { for (int j = 1; j < n / 2 + 2; j++) { if (a[i] >...
#include <iostream> using namespace std; int main() { int n = 0, m = 0, c = 0, a[500001] = {}; cin >> n >> m; for (int i = 1; i <= n; i++) { a[i] = i; } for (int i = 0; i < m; i++) { cin >> c; a[c] = 1; } for (int i = 3; i <= n; i++) { for (int j = 1; j < i / 2 + 2; j++) { if (a[i] >...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["-", 0, 7, 15, 16, 12, 16, 31, 16, 31, 22], ["+", 0, 7, 15, 16, 12, 16, 31, 16, 31, 22]]
1
170
4
#include <algorithm> #include <cstdio> #define MAX_M 20 #define MAX_N 50000 #define MAX_NUM 20000 using namespace std; int C[MAX_M + 5], T[MAX_N + 5]; int main() { int m, n, i, j; scanf("%d %d", &n, &m); for (i = 0; i < m; i++) { scanf("%d", &C[i]); } T[0] = 0; for (i = 1; i < n; i++) { T[i] = M...
#include <algorithm> #include <cstdio> #define MAX_M 20 #define MAX_N 50000 #define MAX_NUM 20000 using namespace std; int C[MAX_M + 5], T[MAX_N + 5]; int main() { int m, n, i, j; scanf("%d %d", &n, &m); for (i = 0; i < m; i++) { scanf("%d", &C[i]); } T[0] = 0; for (i = 1; i <= n; i++) { T[i] = ...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44], ["-", 3, 4, 0, 69, 341, 342, 0, 16, 17, 33], ["-", 3, 4, 0, 69, 341, 342, 0, 16, 12, 13]]
1
207
7
#include <algorithm> #include <cmath> #include <cstdio> #include <functional> #include <iostream> #include <iterator> #include <limits> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin...
#include <algorithm> #include <cmath> #include <cstdio> #include <functional> #include <iostream> #include <iterator> #include <limits> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegi...
[["-", 8, 9, 0, 7, 8, 7, 15, 16, 17, 18], ["+", 8, 9, 0, 7, 8, 7, 15, 16, 17, 19], ["-", 31, 16, 12, 69, 341, 342, 0, 16, 17, 33], ["-", 31, 16, 12, 69, 341, 342, 0, 16, 12, 13]]
1
252
4
#include <iostream> using namespace std; #define INF 1000000000; int main() { int n, m; int c[20]; cin >> n >> m; for (int i = 0; i < m; i++) cin >> c[i]; int T[50000]; for (int i = 0; i <= n; i++) T[i] = INF; T[0] = 0; for (int i = 0; i < m; i++) { for (int j = c[i]; j <= n; j++) { ...
#include <iostream> using namespace std; #define INF 1000000000; int main() { int n, m; int c[20]; cin >> n >> m; for (int i = 0; i < m; i++) cin >> c[i]; int T[50000]; for (int i = 0; i <= n; i++) T[i] = INF; T[0] = 0; for (int i = 0; i < m; i++) { for (int j = c[i]; j <= n; j++) { ...
[["-", 31, 16, 12, 69, 341, 342, 0, 16, 17, 33], ["-", 31, 16, 12, 69, 341, 342, 0, 16, 12, 13]]
1
161
2
#include <algorithm> #include <iostream> #define INF 1e9 using namespace std; // 各コインの価値 int c[21]; // dp[v] := 価値 v 円を支払うときに使用するコインの最小枚数 int dp[50001]; int main() { // n 円を m 種類のコインで支払う int n, m; cin >> n >> m; for (int i = 0; i < m; i++) { cin >> c[i]; } fill(dp, dp + 50001, INF); dp[0] = 1;...
#include <algorithm> #include <iostream> #define INF 1e9 using namespace std; // 各コインの価値 int c[21]; // dp[v] := 価値 v 円を支払うときに使用するコインの最小枚数 int dp[50001]; int main() { // n 円を m 種類のコインで支払う int n, m; cin >> n >> m; for (int i = 0; i < m; i++) { cin >> c[i]; } fill(dp, dp + 50001, INF); dp[0] = 0;...
[["-", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13]]
1
163
21
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int a[20]; for (int i = 0; i < m; i++) { cin >> a[i]; } int x[60001]; for (int i = 0; i <= 60000; i++) { x[i] = 60000; } x[0] = 0; for (int i = 0; i <= n; i++) { for (int j = 0; j < m; j++) { if (x...
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int a[20]; for (int i = 0; i < m; i++) { cin >> a[i]; } int x[60001]; for (int i = 0; i <= 60000; i++) { x[i] = 60000; } x[0] = 0; for (int i = 0; i <= n; i++) { for (int j = 0; j < m; j++) { if (x...
[["-", 0, 16, 31, 69, 341, 342, 0, 16, 17, 33], ["-", 31, 69, 341, 342, 0, 16, 12, 69, 28, 22], ["-", 341, 342, 0, 16, 12, 69, 341, 342, 0, 70], ["-", 341, 342, 0, 16, 12, 69, 341, 342, 0, 22], ["-", 341, 342, 0, 16, 12, 69, 341, 342, 0, 73]]
1
202
5
#include <bits/stdc++.h> #define lb long double #define N 110 #define pi acos(-1) #define eps 1e-10 using namespace std; struct Po { lb x, y; } a[N], yu; int n; lb r, ansn; Po operator-(Po x, Po y) { return (Po){x.x - y.x, x.y - y.y}; } Po operator+(Po x, Po y) { return (Po){x.x + y.x, x.y + y.y}; } lb operator*(Po x...
#include <bits/stdc++.h> #define lb long double #define N 110 #define pi acos(-1) #define eps 1e-10 using namespace std; struct Po { lb x, y; } a[N], yu; int n; lb r, ansn; Po operator-(Po x, Po y) { return (Po){x.x - y.x, x.y - y.y}; } Po operator+(Po x, Po y) { return (Po){x.x + y.x, x.y + y.y}; } lb operator*(Po x...
[["-", 0, 37, 0, 23, 0, 16, 12, 16, 17, 72], ["+", 0, 37, 0, 23, 0, 16, 12, 16, 17, 33]]
1
922
2
#include <bits/stdc++.h> using namespace std; const double EPS = 1e-8, PI = acos(-1); inline bool eq(double a, double b) { return fabs(b - a) < EPS; } using Point = complex<double>; Point operator*(const Point &p, const double &d) { return Point(real(p) * d, imag(p) * d); } istream &operator>>(istream &is, Poin...
#include <bits/stdc++.h> using namespace std; const double EPS = 1e-8, PI = acos(-1); inline bool eq(double a, double b) { return fabs(b - a) < EPS; } using Point = complex<double>; Point operator*(const Point &p, const double &d) { return Point(real(p) * d, imag(p) * d); } istream &operator>>(istream &is, Poin...
[["-", 8, 9, 0, 37, 0, 83, 0, 16, 17, 72], ["+", 8, 9, 0, 37, 0, 83, 0, 16, 17, 33], ["-", 8, 9, 0, 37, 0, 83, 0, 16, 17, 33], ["+", 8, 9, 0, 37, 0, 83, 0, 16, 17, 72]]
1
5,195
4
n, r = list(map(int, input().split())) P = [list(map(int, input().split())) for i in range(n)] from math import sqrt, atan2 def intersection01(cx, cy, r, x1, y1, x2, y2): xd = x2 - x1; yd = y2 - y1 X = x1 - cx; Y = y1 - cy a = xd**2 + yd**2 b = xd * X + yd * Y c = X**2 + Y**2 - r**2 D = b**2 -...
n, r = list(map(int, input().split())) P = [list(map(int, input().split())) for i in range(n)] from math import sqrt, atan2 def intersection01(cx, cy, r, x1, y1, x2, y2): xd = x2 - x1; yd = y2 - y1 X = x1 - cx; Y = y1 - cy a = xd**2 + yd**2 b = xd * X + yd * Y c = X**2 + Y**2 - r**2 D = b**2 -...
[["+", 0, 652, 3, 4, 0, 657, 31, 557, 0, 654], ["+", 0, 652, 3, 4, 0, 657, 31, 557, 0, 6], ["+", 0, 652, 3, 4, 0, 657, 31, 557, 0, 655], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 109]]
5
451
4
#include <stdio.h> #include <stdlib.h> #define INF 100000 int getmin(int n, int m, int *c); int main(void) { int i, ans, n, m, *c; scanf("%d%d", &n, &m); c = (int *)malloc(sizeof(int) * m); for (i = 0; i < m; i++) { scanf("%d", &c[i]); } ans = getmin(n, m, c); printf("%d\n", ans); free(c); ret...
#include <stdio.h> #include <stdlib.h> #define INF 100000 int getmin(int n, int m, int *c); int main(void) { int i, ans, n, m, *c; scanf("%d%d", &n, &m); c = (int *)malloc(sizeof(int) * m); for (i = 0; i < m; i++) { scanf("%d", &c[i]); } ans = getmin(n, m, c); printf("%d\n", ans); free(c); ret...
[["-", 0, 14, 8, 9, 0, 7, 10, 11, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 10, 11, 12, 13], ["-", 8, 9, 0, 57, 15, 23, 0, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 17, 20]]
0
287
4
/*http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_A&lang=jp*/ #include <stdio.h> int main(void) { int n, m, i, j, min; min = 50000; //??\?????? int coin[21]; scanf("%d %d", &n, &m); for (i = 1; i < m + 1; i++) { scanf("%d", &coin[i]); } //????????????????????????,0?????????MAX?????...
/*http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_A&lang=jp*/ #include <stdio.h> int main(void) { int n, m, i, j, min; min = 50000; //??\?????? int coin[21]; scanf("%d %d", &n, &m); for (i = 1; i < m + 1; i++) { scanf("%d", &coin[i]); } //????????????????????????,0?????????MAX?????...
[["-", 0, 16, 12, 69, 28, 69, 71, 16, 17, 33], ["-", 0, 16, 12, 69, 28, 69, 71, 16, 12, 13], ["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 45], ["-", 0, 11, 12, 69, 28, 69, 71, 16, 17, 33], ["-", 0, 11, 12, 69, 28, 69, 71, 16, 12, 13], ["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 46]]
0
302
6
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_A // Combinatorial - Coin Changing Problem // status: [] //#define SUBMIT #include <algorithm> #include <cstring> #include <iostream> #include <numeric> #include <sstream> #include <vector> using namespace std; using ui64 = unsigned long long; using i...
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_A // Combinatorial - Coin Changing Problem // status: [] #define SUBMIT #include <algorithm> #include <cstring> #include <iostream> #include <numeric> #include <sstream> #include <vector> using namespace std; using ui64 = unsigned long long; using i64...
[["+", 36, 36, 36, 36, 0, 30, 0, 58, 0, 148], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 141, 22]]
1
273
2
#include <algorithm> #include <cctype> #include <cmath> #include <cstring> #include <iostream> #include <string> #include <utility> #include <vector> #define REP(i, n) for (int i = 0; i < n; i++) #define REPR(i, n) for (int i = n; i >= 0; i--) #define FOR(i, m, n) for (int i = m; i < n; i++) #define FORR(i, m, n) for ...
#include <algorithm> #include <cctype> #include <cmath> #include <cstring> #include <iostream> #include <string> #include <utility> #include <vector> #define REP(i, n) for (int i = 0; i < n; i++) #define REPR(i, n) for (int i = n; i >= 0; i--) #define FOR(i, m, n) for (int i = m; i < n; i++) #define FORR(i, m, n) for ...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["-", 0, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 0, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["-", 31, 69, 28, 69, 341, 342, 0, 16, 17, 33], ["-", 31, 69, 28, 69, 341, 342, 0, 16, 12, 13]]
1
346
6
#include <algorithm> #include <cctype> #include <cmath> #include <cstring> #include <iostream> #include <string> #include <utility> #include <vector> #define REP(i, n) for (int i = 0; i < n; i++) #define REPR(i, n) for (int i = n; i >= 0; i--) #define FOR(i, m, n) for (int i = m; i < n; i++) #define FORR(i, m, n) for ...
#include <algorithm> #include <cctype> #include <cmath> #include <cstring> #include <iostream> #include <string> #include <utility> #include <vector> #define REP(i, n) for (int i = 0; i < n; i++) #define REPR(i, n) for (int i = n; i >= 0; i--) #define FOR(i, m, n) for (int i = m; i < n; i++) #define FORR(i, m, n) for ...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["-", 0, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 0, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["-", 31, 69, 28, 69, 341, 342, 0, 16, 17, 33], ["-", 31, 69, 28, 69, 341, 342, 0, 16, 12, 13]]
1
346
6
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define P pair<ll, ll> #define FOR(I, A, B) for (ll I = (A); I < (B); ++I) #define FORR(I, A, B) for (ll I = (B - 1); I >= (A); --I) const ll INF = 1e18 + 7; const ll MOD = 1e9 + 7; int main() { ios::sync_with_stdio(false); cin.tie(0); ll n, m; ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define P pair<ll, ll> #define FOR(I, A, B) for (ll I = (A); I < (B); ++I) #define FORR(I, A, B) for (ll I = (B - 1); I >= (A); --I) const ll INF = 1e18 + 7; const ll MOD = 1e9 + 7; int main() { ios::sync_with_stdio(false); cin.tie(0); ll n, m; ...
[["-", 8, 9, 0, 9, 0, 1, 0, 2, 63, 22], ["+", 8, 9, 0, 9, 0, 1, 0, 2, 63, 22], ["-", 51, 16, 31, 16, 12, 69, 341, 342, 0, 22], ["+", 51, 16, 31, 16, 12, 69, 341, 342, 0, 22]]
1
211
4
#include <cmath> #include <iostream> #include <vector> template <typename T> auto print(std::vector<T> array, bool reverse = false) -> void { if (reverse) { auto iterator = array.rbegin(); std::cout << *iterator; iterator++; for (; iterator != array.rend(); ++iterator) { std::cout << " " << *it...
#include <cmath> #include <iostream> #include <vector> template <typename T> auto print(std::vector<T> array, bool reverse = false) -> void { if (reverse) { auto iterator = array.rbegin(); std::cout << *iterator; iterator++; for (; iterator != array.rend(); ++iterator) { std::cout << " " << *it...
[["-", 31, 16, 12, 69, 341, 342, 0, 16, 17, 33], ["-", 31, 16, 12, 69, 341, 342, 0, 16, 12, 13]]
1
370
2
#include <algorithm> #include <iostream> using namespace std; int main() { int N, M; cin >> N >> M; vector<int> kind(M); for (int i = 0; i < M; ++i) cin >> kind[i]; sort(kind.begin(), kind.end()); vector<int> dp(N + 1, N); dp[0] = 0; for (int i = 0; i < M; ++i) for (int j = kind[i]; j <= N; +...
#include <algorithm> #include <iostream> using namespace std; int main() { int N, M; cin >> N >> M; vector<int> kind(M); for (int i = 0; i < M; ++i) cin >> kind[i]; sort(kind.begin(), kind.end()); vector<int> dp(N + 1, N); dp[0] = 0; for (int i = 0; i < M; ++i) for (int j = kind[i]; j <= N; +...
[["-", 341, 342, 0, 16, 12, 69, 341, 342, 0, 22], ["+", 341, 342, 0, 16, 12, 69, 341, 342, 0, 22]]
1
158
2
#include <iostream> #include <stdlib.h> using namespace std; int comp(const void *a, const void *b) { return *(int *)a - *(int *)b; } int main() { int n, m, c[20], T[50000]; cin >> n >> m; for (int i = 0; i < m; i++) { cin >> c[i]; } qsort(c, m, sizeof(int), comp); for (int j = 0; j <= n; j++) { ...
#include <iostream> #include <stdlib.h> using namespace std; int comp(const void *a, const void *b) { return *(int *)a - *(int *)b; } int main() { int n, m, c[20], T[50001]; cin >> n >> m; for (int i = 0; i < m; i++) { cin >> c[i]; } qsort(c, m, sizeof(int), comp); for (int j = 0; j <= n; j++) { ...
[["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["-", 31, 16, 12, 69, 341, 342, 0, 16, 17, 33], ["-", 31, 16, 12, 69, 341, 342, 0, 16, 12, 13]]
1
220
4
#include <algorithm> #include <iostream> using namespace std; int main() { int result, i, j, n, m, c[21], t[50001]; cin >> n >> m; for (i = 0; i < m; i++) { cin >> c[i]; } for (j = 0; j <= n; j++) { t[j] = 10001; } t[0] = 0; for (i = 0; i < m; i++) { for (j = c[i]; j <= n; j++) { ...
#include <algorithm> #include <iostream> using namespace std; int main() { int result, i, j, n, m, c[21], t[50001]; cin >> n >> m; for (i = 0; i < m; i++) { cin >> c[i]; } for (j = 0; j <= n; j++) { t[j] = 10001; } t[0] = 0; for (i = 0; i < m; i++) { for (j = c[i]; j <= n; j++) { ...
[["-", 0, 11, 12, 69, 341, 342, 0, 16, 17, 33], ["-", 0, 11, 12, 69, 341, 342, 0, 16, 12, 13]]
1
170
25
#include <cstring> #include <iostream> #define rep(i, n) for (int i = 0; i < (n); i++) const int INF = 1e9; using namespace std; int m, n; int c[21]; int dp[100005][21]; int dfs(int i, int sum) { if (i == m) { if (n == sum) return 0; else return INF; } if (dp[i][sum] != -1) return dp...
#include <cstring> #include <iostream> #define rep(i, n) for (int i = 0; i < (n); i++) const int INF = 1e9; using namespace std; int m, n; int c[21]; int dp[21][100005]; int dfs(int i, int sum) { if (i == m) { if (n == sum) return 0; else return INF; } if (dp[i][sum] != -1) { return ...
[["-", 0, 30, 0, 43, 49, 80, 49, 80, 81, 13], ["+", 0, 30, 0, 43, 49, 80, 49, 80, 81, 13], ["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 57, 64, 9, 0, 45], ["+", 0, 14, 8, 9, 0, 57, 64, 9, 0, 46]]
1
201
8
#include <algorithm> #include <iostream> #define INF 1000000 using namespace std; int dp[50000]; int main() { int n, m; int c[20]; cin >> n >> m; for (int i = 0; i < m; i++) { cin >> c[i]; } for (int i = 0; i <= n; i++) { dp[i] = INF; } dp[0] = 0; for (int i = 0; i < m; i++) { for (int j =...
#include <algorithm> #include <iostream> #define INF 1000000 using namespace std; int dp[50000]; int main() { int n, m; int c[20]; cin >> n >> m; for (int i = 0; i < m; i++) { cin >> c[i]; } for (int i = 0; i <= n; i++) { dp[i] = INF; } dp[0] = 0; for (int i = 0; i < m; i++) { for (int j =...
[["-", 0, 7, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 17, 19], ["-", 31, 16, 12, 69, 341, 342, 0, 16, 17, 33], ["-", 31, 16, 12, 69, 341, 342, 0, 16, 12, 13]]
1
164
4
#include <iostream> using namespace std; int main() { int n, m, C[20], T[50000]; cin >> n >> m; for (int i = 0; i < m; i++) cin >> C[i]; for (int i = 0; i < n; i++) T[i] = 21; T[0] = 0; for (int i = 0; i < m; i++) { for (int j = C[i]; j <= n; j++) { if (T[j] > T[j - C[i]] + 1) T...
#include <iostream> using namespace std; int main() { int n, m, C[20], T[50001]; cin >> n >> m; for (int i = 0; i < m; i++) cin >> C[i]; for (int i = 0; i <= n; i++) T[i] = 100000; T[0] = 0; for (int i = 0; i < m; i++) { for (int j = C[i]; j <= n; j++) { if (T[j] > T[j - C[i]] + 1) ...
[["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["-", 8, 9, 0, 7, 8, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 7, 8, 1, 0, 11, 12, 13], ["-", 31, 16, 12, 69, 341, 342, 0, 16, 17, 33], ["-", 31, 16, 12, 69,...
1
169
8
def solve_knapsack(w, v, q) n = w.length inf = 1e9.to_i ans = [-inf] * (q + 1) ans[0] = 0 (w.zip(v)).each do |wi, vi| (0..(q-wi)).each do |kkk| k = (q-wi) - kkk ans[k+wi] = [ans[k+wi], ans[k] + vi].max end end ans[q] end if __FILE__ == $0 n, q = gets().split().map(&:to_i) v, w = [], [] n.tim...
def solve_knapsack(w, v, q) n = w.length inf = 1e9.to_i ans = [-inf] * (q + 1) ans[0] = 0 (w.zip(v)).each do |wi, vi| (0..(q-wi)).each do |kkk| k = (q-wi) - kkk ans[k+wi] = [ans[k+wi], ans[k] + vi].max end end ans.max end if __FILE__ == $0 n, q = gets().split().map(&:to_i) v, w = [], [] n.t...
[["-", 0, 493, 0, 735, 8, 736, 0, 742, 0, 70], ["-", 0, 493, 0, 735, 8, 736, 0, 742, 0, 22], ["-", 0, 493, 0, 735, 8, 736, 0, 742, 0, 73], ["+", 0, 493, 0, 735, 8, 736, 0, 652, 17, 131], ["+", 0, 493, 0, 735, 8, 736, 0, 652, 735, 22]]
4
187
5
n, w = gets.split(" ").map(&:to_i) goods = Array.new(n+1) for i in 1..n goods[i] = gets.split(" ").map(&:to_i) end max = 0 v = Array.new(n+1) for j in 0..n v[j] = Array.new(w+1,0) end #v = Array.new(n+1,Array.new(w+1)) #p v #for i in 1..n # v[i][0] = 0 #end #p v #for c in 1..w # v[0][c] = 0 #end #p v #v[0][0] ...
# coding: utf-8 # http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_B&lang=jp "Combinatorial - 0-1 Knapsack Problem" # # 30???????????? # n, w = gets.split(" ").map(&:to_i) goods = Array.new(n+1) for i in 1..n goods[i] = gets.split(" ").map(&:to_i) end max = 0 v = Array.new(n+1) for j in 0..n v[j] =...
[["-", 8, 170, 0, 88, 8, 170, 0, 652, 735, 22], ["-", 0, 88, 8, 170, 0, 652, 3, 4, 0, 22]]
4
211
2
def ramp(t): if t >= 0: return t else: return 0 def heav(t): if t >= 0: return(1) else: return(0) N,W = map(int,input().strip().split(" ")) lst = [] for i in range(N): l = list(map(int,input().strip().split(" "))) lst.append(l) table = [[0 for c in range(W+1)] fo...
def ramp(t): if t >= 0: return t else: return 0 def heav(t): if t >= 0: return(1) else: return(0) N,W = map(int,input().strip().split(" ")) lst = [] for i in range(N): l = list(map(int,input().strip().split(" "))) lst.append(l) table = [[0 for c in range(W+1)] for...
[["-", 3, 4, 0, 657, 31, 206, 206, 652, 63, 22], ["+", 3, 4, 0, 657, 31, 206, 206, 652, 63, 22]]
5
230
2
#Nはアイテム数、Wはナップサックサイズ N,W = map(int,input().split()) #dpテーブルを作成(初期値は0) dp = [[0 for i in range(W + 1)] for j in range(N + 1)] #print(dp) #N個のアイテムのvalueとweightを入れるリストを用意する value = [] weight = [] for i in range(N): v,w = map(int,input().split()) value.append(v) weight.append(w) #print(values) #print(weights...
#Nはアイテム数、Wはナップサックサイズ N,W = map(int,input().split()) #dpテーブルを作成(初期値は0) dp = [[0 for i in range(W + 1)] for j in range(N + 1)] #print(dp) #N個のアイテムのvalueとweightを入れるリストを用意する value = [] weight = [] for i in range(N): v,w = map(int,input().split()) value.append(v) weight.append(w) #print(values) #print(weights...
[["-", 3, 4, 0, 206, 51, 206, 206, 657, 17, 72], ["-", 3, 4, 0, 206, 51, 206, 206, 657, 12, 612], ["-", 0, 652, 3, 4, 0, 206, 206, 657, 17, 72], ["-", 0, 652, 3, 4, 0, 206, 206, 657, 12, 612]]
5
202
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- N,W = map(int,input().split()) v = [0] * (N+1) w = [0] * (N+1) for j in range(1, N+1): v[j], w[j] = map(int,input().split()) dp = [[0 for i in range(W+1)] for j in range(N+1)] for j in range(1, N+1): for i in range(1, W+1): if w[j] <= i: dp[j...
#!/usr/bin/env python3 # -*- coding: utf-8 -*- N,W = map(int,input().split()) v = [0] * (N+1) w = [0] * (N+1) for j in range(1, N+1): v[j], w[j] = map(int,input().split()) dp = [[0 for i in range(W+1)] for j in range(N+1)] for j in range(1, N+1): for i in range(1, W+1): if w[j] <= i: dp[j...
[["+", 0, 652, 3, 4, 0, 206, 51, 206, 0, 70], ["+", 0, 652, 3, 4, 0, 206, 51, 206, 206, 22], ["+", 0, 652, 3, 4, 0, 206, 51, 206, 0, 73], ["+", 0, 1, 0, 652, 3, 4, 0, 206, 0, 70], ["+", 0, 1, 0, 652, 3, 4, 0, 206, 206, 22], ["+", 0, 1, 0, 652, 3, 4, 0, 206, 0, 73]]
5
194
6
N, W = list(map(int, input().split())) v = [0]*N w = [0]*N for i in range(N): v[i], w[i] = list(map(int, input().split())) dp = [0] * (W+1) for i in range(N): for j in range(W, w[i]-1, -1): dp[j] = max(dp[j-w[i]] + v[i], dp[j]) print(dp[W-1])
N, W = list(map(int, input().split())) v = [0]*N w = [0]*N for i in range(N): v[i], w[i] = list(map(int, input().split())) dp = [0] * (W+1) for i in range(N): for j in range(W, w[i]-1, -1): dp[j] = max(dp[j-w[i]] + v[i], dp[j]) print(dp[W])
[["-", 0, 652, 3, 4, 0, 206, 206, 657, 17, 33], ["-", 0, 652, 3, 4, 0, 206, 206, 657, 12, 612]]
5
139
2
N, W = map(int, input().split()) v = [0]*(N+1) w = [0]*(N+1) for i in range(N): v[i], w[i] = map(int, input().split()) dp = [[0 for i in range(W+1)] for j in range(N+1)] for i in range(1, N+1): for j in range(1, W+1): if w[i] <= j: dp[i][j] = max(dp[i-1][j-w[i]]+v[i], dp[i-1][j]) el...
N, W = map(int, input().split()) v = [0]*(N+1) w = [0]*(N+1) for i in range(1, N+1): v[i], w[i] = map(int, input().split()) dp = [[0 for i in range(W+1)] for j in range(N+1)] for i in range(1, N+1): for j in range(1, W+1): if w[i] <= j: dp[i][j] = max(dp[i-1][j-w[i]]+v[i], dp[i-1][j]) ...
[["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 21], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
194
4
l=[] n,W=input().split() n=int(n) W=int(W) for i in range(n): item=list(map(int,input().split())) l.append([item[1],item[0]]) dp=[[False for j in range(W)] for i in range(n)] def solve(i,w): if dp[i][w]==False: if i==n: res=(0) elif w-l[i][0]<0: res=(solve(i+1,w)) else: a=solve(i+1,w) b=l[i][1]+...
l=[] n,W=input().split() n=int(n) W=int(W) for i in range(n): item=list(map(int,input().split())) l.append([item[1],item[0]]) dp=[[False for j in range(W+1)] for i in range(n+1)] def solve(i,w): if dp[i][w]==False: if i==n: res=(0) elif w-l[i][0]<0: res=(solve(i+1,w)) else: a=solve(i+1,w) b=l[i][...
[["+", 0, 659, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 659, 12, 652, 3, 4, 0, 657, 12, 612]]
5
232
4
N, W = list(map(int, input().split())) v_list = list() w_list = list() for _ in range(N): v, w = list(map(int, input().split())) v_list.append(v) w_list.append(w) sum_v_table = [[0]*(W+1)]*(N+1) for i in range(1, N+1): item = v_list[i-1], w_list[i-1] for w in range(1, W+1): if item[1] > w...
N, W = list(map(int, input().split())) v_list = list() w_list = list() for _ in range(N): v, w = list(map(int, input().split())) v_list.append(v) w_list.append(w) sum_v_table = [[0]*(W+1) for _ in range(N+1)] for i in range(1, N+1): item = v_list[i-1], w_list[i-1] for w in range(1, W+1): ...
[["-", 0, 1, 0, 662, 12, 657, 31, 634, 0, 73], ["-", 0, 656, 0, 1, 0, 662, 12, 657, 17, 48], ["+", 0, 1, 0, 662, 12, 658, 0, 659, 0, 88], ["+", 0, 1, 0, 662, 12, 658, 0, 659, 31, 22], ["+", 0, 1, 0, 662, 12, 658, 0, 659, 0, 267], ["+", 0, 662, 12, 658, 0, 659, 12, 652, 63, 22], ["+", 0, 656, 0, 1, 0, 662, 12, 658, 0, 7...
5
205
7
N,W = map(int,input().split()) v = [0]*N;w = [0]*N for i in range(N): v[i],w[i] = map(int,input().split()) value = [0 for i in range(W+1)] for i in range(N): for j in range(W+1,-1,-1): if j<w[i]: value[j] = value[j] else: value[j] = max(value[j],value[j-w[i]]+v[i]) pri...
N,W = map(int,input().split()) v = [0]*N;w = [0]*N for i in range(N): v[i],w[i] = map(int,input().split()) value = [0 for i in range(W+1)] for i in range(N): for j in range(W,-1,-1): if j<w[i]: value[j] = value[j] else: value[j] = max(value[j],value[j-w[i]]+v[i]) print...
[["-", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
152
2
N, W = map(int, input().split()) v = [0] * N w = [0] * N dp = [[-1 for i in range(W + 1)] for j in range(N + 1)] for i in range(N): v[i], w[i] = map(int, input().split()) for i in range(N-1, -1, -1): for j in range(W + 1): if j < w[i]: dp[i][j] = dp[i + 1][j] else: dp[...
N, W = map(int, input().split()) v = [0] * N w = [0] * N dp = [[0 for i in range(W + 1)] for j in range(N + 1)] for i in range(N): v[i], w[i] = map(int, input().split()) for i in range(N - 1, -1, -1): for j in range(W + 1): if j < w[i]: dp[i][j] = dp[i + 1][j] else: dp...
[["-", 0, 662, 12, 658, 8, 658, 8, 664, 17, 33], ["-", 0, 662, 12, 658, 8, 658, 8, 664, 28, 612], ["+", 0, 1, 0, 662, 12, 658, 8, 658, 8, 612]]
5
189
3
# 0-1 Knapsack Problem N, W = [int(x) for x in input().split()] items = [] for i in range(N): items.append(tuple(int(x) for x in input().split())) DP = [0] * (W+1) for i in range(N): v, w = items[i] for j in range(W, w-1, -1): DP[j] = max(DP[j], v + DP[j-w]) print(DP[-1][-1])
# 0-1 Knapsack Problem N, W = [int(x) for x in input().split()] items = [] for i in range(N): items.append(tuple(int(x) for x in input().split())) DP = [0] * (W+1) for i in range(N): v, w = items[i] for j in range(W, w-1, -1): DP[j] = max(DP[j], v + DP[j-w]) print(DP[-1])
[["-", 0, 1, 0, 652, 3, 4, 0, 206, 0, 70], ["-", 0, 652, 3, 4, 0, 206, 206, 664, 17, 33], ["-", 0, 652, 3, 4, 0, 206, 206, 664, 28, 612], ["-", 0, 1, 0, 652, 3, 4, 0, 206, 0, 73]]
5
130
4
N,W=map(int,input().split()) C=[0]*-~W for _ in[0]*N: v,w=map(int,input().split()) for i in range(W,w-1,-1): t=v+C[i-w] if t>C[i]:C[j]=t print(C[W])
N,W=map(int,input().split()) C=[0]*-~W for _ in[0]*N: v,w=map(int,input().split()) for i in range(W,w-1,-1): t=v+C[i-w] if t>C[i]:C[i]=t print(C[W])
[["-", 64, 196, 0, 1, 0, 662, 31, 206, 206, 22], ["+", 64, 196, 0, 1, 0, 662, 31, 206, 206, 22]]
5
96
2
N,W = map(int,input().split()) value = [0] weight = [0] for i in range(N): v,w = map(int,input().split()) value.append(v) weight.append(w) dp = [[0]*(N+10) for _ in range(W+10)] #dp[k][w]はk番目までの荷物を使ってw以内に抑えた時の最大値 #dp[0][_] = dp[_][w] = 0と定義する(荷物は1番目、2番目、・・・、N番目と定義する) for w in range(1,W+2): for k in ra...
N,W = map(int,input().split()) value = [0] weight = [0] for i in range(N): v,w = map(int,input().split()) value.append(v) weight.append(w) dp = [[0]*(W+3) for _ in range(N+3)] for w in range(1,W+1): for k in range(1,N+1): if weight[k] > w: dp[k][w] = dp[k-1][w] else: ...
[["-", 12, 658, 8, 657, 12, 23, 0, 657, 31, 22], ["+", 12, 658, 8, 657, 12, 23, 0, 657, 31, 22], ["-", 12, 658, 8, 657, 12, 23, 0, 657, 12, 612], ["+", 12, 658, 8, 657, 12, 23, 0, 657, 12, 612], ["-", 0, 659, 12, 652, 3, 4, 0, 657, 31, 22], ["+", 0, 659, 12, 652, 3, 4, 0, 657, 31, 22], ["-", 0, 659, 12, 652, 3, 4, 0, 6...
5
187
10
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = Integer.parseInt(sc.next()); int WW = Integer.parseInt(sc.next()); int[] v = new int[N + 1]; int[] w = new int[N + 1]; for (int i = 1; i < N + 1; i++) { v[...
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = Integer.parseInt(sc.next()); int WW = Integer.parseInt(sc.next()); int[] v = new int[N + 1]; int[] w = new int[N + 1]; for (int i = 1; i < N + 1; i++) { v[...
[["-", 8, 196, 0, 7, 502, 503, 49, 200, 51, 499], ["+", 0, 7, 502, 503, 49, 200, 51, 504, 516, 22], ["+", 0, 7, 502, 503, 49, 200, 51, 504, 0, 70], ["+", 0, 7, 502, 503, 49, 200, 51, 504, 71, 22], ["+", 0, 7, 502, 503, 49, 200, 51, 504, 0, 73]]
3
261
5
#include <stdio.h> #include <stdlib.h> #include <string.h> struct Item { int value; int weight; }; int max(int x, int y) { if (x >= y) return x; else return y; } int main() { int N, W; int i, w; struct Item *item; scanf("%d %d", &N, &W); int C[N + 1][W + 1]; item = malloc(sizeof(item) * (...
#include <stdio.h> #include <stdlib.h> #include <string.h> struct Item { int value; int weight; }; int max(int x, int y) { if (x >= y) return x; else return y; } int main() { int N, W; int i, w; struct Item *item; scanf("%d %d", &N, &W); int C[N + 1][W + 1]; item = malloc(sizeof(item) * (...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
335
2
#include <iostream> using namespace std; int main() { int n; cin >> n; int W; cin >> W; int v[n]; int w[n]; for (int i = 0; i < n; i++) { cin >> v[i] >> w[i]; } int DP[n + 1][W + 1]; for (int i = 0; i <= W; i++) { DP[0][i] = 0; } for (int i = 1; i <= n; i++) { for (int j = 0; j <=...
#include <iostream> using namespace std; int main() { int n; cin >> n; int W; cin >> W; int v[n]; int w[n]; for (int i = 0; i < n; i++) { cin >> v[i] >> w[i]; } int DP[n + 1][W + 1]; for (int i = 0; i <= W; i++) { DP[0][i] = 0; } for (int i = 1; i <= n; i++) { for (int j = 0; j <=...
[["+", 31, 69, 28, 69, 341, 342, 0, 16, 17, 33], ["+", 31, 69, 28, 69, 341, 342, 0, 16, 12, 13]]
1
265
2
#include <algorithm> #include <iostream> #include <memory.h> using namespace std; int main() { int n, W; int v[101], w[101]; int dp[101][1001]; cin >> n >> W; for (int i = 0; i < n; i++) { cin >> v[i] >> w[i]; } for (int i = 1; i <= n; i++) { for (int i2 = 0; i2 <= W; i2++) { if (i2 - w[i - ...
#include <algorithm> #include <iostream> #include <memory.h> using namespace std; int main() { int n, W; int v[101], w[101]; int dp[101][10001]; cin >> n >> W; for (int i = 0; i < n; i++) { cin >> v[i] >> w[i]; } for (int i = 1; i <= n; i++) { for (int i2 = 0; i2 <= W; i2++) { if (i2 - w[i -...
[["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 16, 12, 69, 341, 342, 0, 16, 17, 33], ["+", 0, 16, 12, 69, 341, 342, 0, 16, 12, 13]]
1
192
4
from sys import stdin readline = stdin.readline n, total_wait = map(int, readline().split()) value_wait = [list(map(int, readline().split())) for _ in range(n)] value_wait.sort(key=operator.itemgetter(1), reverse=True) dp = [0] * (total_wait + 1) for ni, (v, w) in enumerate(value_wait): for tw in range(w, total...
from sys import stdin import operator readline = stdin.readline n, total_wait = map(int, readline().split()) value_wait = [list(map(int, readline().split())) for _ in range(n)] value_wait.sort(key=operator.itemgetter(1), reverse=True) dp = [0] * (total_wait + 1) for ni, (v, w) in enumerate(value_wait): for tw ...
[["+", 36, 36, 36, 36, 0, 656, 0, 596, 0, 487], ["+", 36, 36, 0, 656, 0, 596, 141, 673, 0, 22]]
5
141
2
N, W = map(int, input().split()) value = [] weight = [] dp = [0 for _ in range(W + 1)] for i in range(N): v, w = map(int, input().split()) for j in range(W+1): if j >= w: dp[j] = max(dp[j], dp[j - w] + v) else: break print(dp[W])
N, W = map(int, input().split()) value = [] weight = [] dp = [0 for _ in range(W + 1)] for i in range(N): v, w = map(int, input().split()) for j in range(W+1): if j >= w: dp[j] = max(dp[j], dp[j - w] + v) print(dp[W])
[["-", 0, 7, 8, 196, 0, 57, 75, 76, 0, 95], ["-", 0, 7, 8, 196, 0, 57, 75, 76, 0, 102], ["-", 0, 57, 75, 76, 8, 196, 0, 93, 0, 94]]
5
108
3
#include <algorithm> #include <iostream> #include <queue> #define ll long long #define INF 100000000000000 using namespace std; int main() { ll N, W; cin >> N >> W; ll v[100], w[100]; for (ll i = 0; i < N; i++) { cin >> v[i] >> w[i]; } ll dp[N + 1][W + 1]; for (ll i = 0; i < N + 1; i++) { for (ll...
#include <algorithm> #include <iostream> #include <queue> #define ll long long #define INF 100000000000000 using namespace std; int main() { ll N, W; cin >> N >> W; ll v[100], w[100]; for (ll i = 0; i < N; i++) { cin >> v[i] >> w[i]; } ll dp[N + 1][W + 1]; for (ll i = 0; i < N + 1; i++) { for (ll...
[["+", 51, 16, 12, 69, 341, 342, 0, 16, 17, 33], ["+", 51, 16, 12, 69, 341, 342, 0, 16, 12, 13]]
1
247
2
#include <algorithm> #include <functional> #include <iostream> #include <list> #include <map> #include <queue> #include <stack> #include <stdio.h> #include <string> #include <time.h> #include <vector> using namespace std; int dp[101][100001] = {0}; int N, v[100], w[100], W; int main(void) { int sum = 0; scanf("%d...
#include <algorithm> #include <functional> #include <iostream> #include <list> #include <map> #include <queue> #include <stack> #include <stdio.h> #include <string> #include <time.h> #include <vector> using namespace std; int dp[101][100001] = {0}; int N, v[100], w[100], W; int main(void) { int sum = 0; scanf("%d...
[["+", 12, 69, 28, 69, 341, 342, 0, 16, 17, 33], ["+", 12, 69, 28, 69, 341, 342, 0, 16, 12, 13], ["-", 0, 11, 12, 69, 341, 342, 0, 16, 17, 33], ["-", 0, 11, 12, 69, 341, 342, 0, 16, 12, 13], ["+", 0, 16, 31, 69, 341, 342, 0, 16, 31, 22]]
1
247
5
#include <iostream> #include <vector> using namespace std; int main() { int n, W; std::cin >> n >> W; vector<int> v(n), w(n); for (int i = 0; i < n; i++) { std::cin >> v[i] >> w[i]; } int dp[n + 1][W + 1]; for (int i = 0; i <= n; i++) for (int j = 0; j <= W; j++) dp[i][j] = 0; for (int i...
#include <iostream> #include <vector> using namespace std; int main() { int n, W; std::cin >> n >> W; vector<int> v(n), w(n); for (int i = 0; i < n; i++) { std::cin >> v[i] >> w[i]; } int dp[n + 1][W + 1]; for (int i = 0; i <= n; i++) for (int j = 0; j <= W; j++) dp[i][j] = 0; for (int i...
[["-", 3, 4, 0, 16, 12, 69, 341, 342, 0, 22], ["+", 3, 4, 0, 16, 12, 69, 341, 342, 0, 22]]
1
263
2
#include <algorithm> #include <iomanip> #include <iostream> #include <vector> #define debug(x) cout << #x << "==" << x << endl; const int INF = 1e+8; using namespace std; template <typename T> vector<vector<T>> make_2d_vector(size_t rows, size_t cols, T init) { return vector<vector<T>>(rows, vector<T>(cols, init)...
#include <algorithm> #include <iomanip> #include <iostream> #include <vector> #define debug(x) cout << #x << "==" << x << endl; const int INF = 1e+8; using namespace std; template <typename T> vector<vector<T>> make_2d_vector(size_t rows, size_t cols, T init) { return vector<vector<T>>(rows, vector<T>(cols, init)...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["-", 12, 69, 28, 69, 341, 342, 0, 16, 17, 33], ["-", 12, 69, 28, 69, 341, 342, 0, 16, 12, 13]]
1
307
6
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>; #define REPS(i, a, n) for (int i = (a); i < (n); ++i) #define REP(i, n) REPS(i, 0, n) #define RREP(i, n) REPS(i, 1, n + 1) #define DEPS(i, a, n)...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>; #define REPS(i, a, n) for (int i = (a); i < (n); ++i) #define REP(i, n) REPS(i, 0, n) #define RREP(i, n) REPS(i, 1, n + 1) #define DEPS(i, a, n)...
[["-", 31, 69, 28, 69, 341, 342, 0, 16, 17, 33], ["-", 31, 69, 28, 69, 341, 342, 0, 16, 12, 13]]
1
549
2
#define _CRT_SECURE_NO_WARNINGS #define _USE_MATH_DEFINES #include <algorithm> #include <iostream> using namespace std; int dp[101][10001], w[101], v[101], n; int main() { int W; cin >> n; cin >> W; for (int i = 0; i < n; i++) { cin >> v[i] >> w[i]; } for (int i = 0; i <= n; i++) dp[i][0] = 0; fo...
#define _CRT_SECURE_NO_WARNINGS #define _USE_MATH_DEFINES #include <algorithm> #include <iostream> using namespace std; int dp[101][10001], w[101], v[101], n; int main() { int W; cin >> n; cin >> W; for (int i = 1; i <= n; i++) { cin >> v[i] >> w[i]; } for (int i = 0; i <= n; i++) dp[i][0] = 0; fo...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]]
1
246
4
#define _CRT_SECURE_NO_WARNINGS #define _USE_MATH_DEFINES //#include "MyMath.h" //#include "DataStructure.h" #include <algorithm> #include <functional> #include <iostream> #include <queue> #include <vector> using namespace std; typedef pair<int, int> p; const int INF = 1000000000; int main() { int n, W; cin >> n >>...
#define _CRT_SECURE_NO_WARNINGS #define _USE_MATH_DEFINES //#include "MyMath.h" //#include "DataStructure.h" #include <algorithm> #include <functional> #include <iostream> #include <queue> #include <vector> using namespace std; typedef pair<int, int> p; const int INF = 1000000000; int main() { int n, W; cin >> n >>...
[["+", 0, 11, 12, 2, 3, 4, 0, 16, 17, 72], ["+", 12, 2, 3, 4, 0, 16, 12, 69, 28, 22], ["+", 3, 4, 0, 16, 12, 69, 341, 342, 0, 70], ["+", 3, 4, 0, 16, 12, 69, 341, 342, 0, 22], ["+", 3, 4, 0, 16, 12, 69, 341, 342, 0, 73]]
1
238
5
#include "bits/stdc++.h" #define REP(i, n) for (ll i = 0; i < n; ++i) #define RREP(i, n) for (ll i = n - 1; i >= 0; --i) #define FOR(i, m, n) for (ll i = m; i < n; ++i) #define RFOR(i, m, n) for (ll i = n - 1; i >= m; --i) #define ALL(v) (v).begin(), (v).end() #define PB(a) push_back(a) #define UNIQUE(v) v.erase(uniqu...
#include "bits/stdc++.h" #define REP(i, n) for (ll i = 0; i < n; ++i) #define RREP(i, n) for (ll i = n - 1; i >= 0; --i) #define FOR(i, m, n) for (ll i = m; i < n; ++i) #define RFOR(i, m, n) for (ll i = n - 1; i >= m; --i) #define ALL(v) (v).begin(), (v).end() #define PB(a) push_back(a) #define UNIQUE(v) v.erase(uniqu...
[["-", 31, 69, 28, 69, 28, 2, 3, 4, 0, 22], ["+", 28, 69, 28, 2, 3, 4, 0, 16, 31, 22], ["+", 28, 69, 28, 2, 3, 4, 0, 16, 17, 72], ["+", 28, 69, 28, 2, 3, 4, 0, 16, 12, 13], ["-", 0, 11, 31, 69, 28, 69, 341, 342, 0, 22], ["+", 0, 11, 31, 69, 28, 69, 341, 342, 0, 13], ["-", 0, 1, 0, 11, 31, 69, 341, 342, 0, 13], ["+", 0,...
1
386
8
#include <algorithm> #include <iostream> #include <vector> using namespace std; int C[105][10005]; struct items { int value, weight; }; int main() { int N, W; int a, b; items item[105]; cin >> N >> W; for (int i = 0; i <= N; i++) { cin >> a >> b; item[i].value = a; item[i].weight = b; } ...
#include <algorithm> #include <iostream> #include <vector> using namespace std; int C[105][10005]; struct items { int value, weight; }; int main() { int N, W; int a, b; items item[105]; cin >> N >> W; for (int i = 1; i <= N; i++) { cin >> a >> b; item[i].value = a; item[i].weight = b; } ...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
269
2
#include <iostream> using namespace std; #define MAX_N 100 #define MAX_W 10000 void solve(); int N, W; int v[MAX_N + 1], w[MAX_N + 1]; int dp[MAX_N + 1][MAX_W + 1]; int main() { cin >> N >> W; //??????0 v[0] = 0; w[0] = 0; //??????1~ for (int i = 1; i <= N; i++) { cin >> v[i] >> w[i]; } sol...
#include <iostream> using namespace std; #define MAX_N 100 #define MAX_W 10000 void solve(); int N, W; int v[MAX_N + 1], w[MAX_N + 1]; int dp[MAX_N + 1][MAX_W + 1]; int main() { cin >> N >> W; //??????0 v[0] = 0; w[0] = 0; //??????1~ for (int i = 1; i <= N; i++) { cin >> v[i] >> w[i]; } sol...
[["-", 3, 4, 0, 16, 12, 69, 341, 342, 0, 22], ["+", 3, 4, 0, 16, 12, 69, 341, 342, 0, 22]]
1
238
2
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int n, w, w1[101], v1[101]; cin >> n >> w; vector<int> now[n + 1]; for (int i = 0; i < n; i++) cin >> w1[i] >> v1[i]; for (int i = 0; i < n + 1; i++) now[i].assign(w + 1, 0); for (int i = 0; i < n; i++) ...
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int n, w, w1[100], v1[100]; cin >> n >> w; vector<int> now[n + 1]; for (int i = 0; i < n; i++) cin >> v1[i] >> w1[i]; for (int i = 0; i < n + 1; i++) now[i].assign(w + 1, 0); for (int i = 0; i < n; i++) ...
[["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["-", 8, 1, 0, 16, 31, 16, 12, 69, 28, 22], ["+", 8, 1, 0, 16, 31, 16, 12, 69, 28, 22], ["-", 0, 7, 8, 1, 0, 16, 12, 69, 28, 22], ["+", 0, 7, 8, 1, 0, 16, 12, 69, 28, 22]]
1
240
8
#include <iostream> using namespace std; int main() { int N, W; cin >> N >> W; if ((N > 0 || N > 101) && (W < 0 || W > 10001)) { return -1; } int v[N], w[N]; for (int i = 0; i < N; i++) { cin >> v[i] >> w[i]; if ((v[i] < 0 || v[i] > 1001) && (w[i] < 0 || w[i] > 1001)) { return -1; ...
#include <iostream> using namespace std; int main() { int N, W; cin >> N >> W; if ((N > 0 || N > 101) && (W < 0 || W > 10001)) { return -1; } int v[N], w[N]; for (int i = 0; i < N; i++) { cin >> v[i] >> w[i]; if ((v[i] < 0 || v[i] > 1001) && (w[i] < 0 || w[i] > 1001)) { return -1; ...
[["-", 8, 9, 0, 43, 49, 80, 49, 80, 81, 13], ["+", 0, 43, 49, 80, 49, 80, 81, 16, 31, 22], ["+", 0, 43, 49, 80, 49, 80, 81, 16, 17, 72], ["+", 0, 43, 49, 80, 49, 80, 81, 16, 12, 13], ["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 8, 9, 0, 43, 49, 80, 81, 16, 31, 22], ["+", 8, 9, 0, 43, 49, 80, 81, 16, 17, 72], ["+", ...
1
323
8
#include <algorithm> #include <iostream> using namespace std; int n, W; int weight[110], value[110]; int dp[110][1010]; int main() { cin >> n >> W; for (int i = 0; i < n; i++) cin >> weight[i] >> value[i]; for (int w = 0; w <= W; w++) dp[0][W] = 0; for (int i = 0; i < n; i++) { for (int w = 0;...
#include <algorithm> #include <iostream> using namespace std; int n, W; int weight[110], value[110]; int dp[110][10010]; int main() { cin >> n >> W; for (int i = 0; i < n; i++) cin >> value[i] >> weight[i]; for (int w = 0; w <= W; w++) dp[0][W] = 0; for (int i = 0; i < n; i++) { for (int w = 0...
[["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["-", 8, 1, 0, 16, 31, 16, 12, 69, 28, 22], ["+", 8, 1, 0, 16, 31, 16, 12, 69, 28, 22], ["-", 0, 7, 8, 1, 0, 16, 12, 69, 28, 22], ["+", 0, 7, 8, 1, 0, 16, 12, 69, 28, 22]]
1
209
6