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
#include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) for (int i = 0; i < (n); ++i) #define REPr(i, n) for (int i = (n)-1; i >= 0; --i) #define FORq(i, m, n) for (int i = (m); i <= (n); ++i) #define FORqr(i, m, n) for (int i = (n); i >= (m); --i) #define M...
#include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) for (int i = 0; i < (n); ++i) #define REPr(i, n) for (int i = (n)-1; i >= 0; --i) #define FORq(i, m, n) for (int i = (m); i <= (n); ++i) #define FORqr(i, m, n) for (int i = (n); i >= (m); --i) #define M...
[["-", 0, 9, 0, 57, 64, 1, 0, 11, 12, 13], ["+", 0, 57, 64, 1, 0, 11, 12, 16, 31, 22], ["+", 0, 57, 64, 1, 0, 11, 12, 16, 17, 33], ["+", 64, 1, 0, 11, 12, 16, 12, 69, 28, 22], ["+", 0, 11, 12, 16, 12, 69, 341, 342, 0, 70], ["+", 0, 11, 12, 16, 12, 69, 341, 342, 0, 22], ["+", 0, 11, 12, 16, 12, 69, 341, 342, 0, 73]]
1
464
#include <algorithm> #include <array> #include <bitset> #include <cassert> #include <cfloat> #include <chrono> #include <climits> #include <cmath> #include <cstdio> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <sstre...
#include <algorithm> #include <array> #include <bitset> #include <cassert> #include <cfloat> #include <chrono> #include <climits> #include <cmath> #include <cstdio> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <sstre...
[["-", 0, 57, 64, 1, 0, 2, 3, 4, 0, 13], ["+", 0, 57, 64, 1, 0, 2, 3, 4, 0, 13]]
1
968
n=int(input()) arr=list(map(int,input().split())) ans=sum(arr) if n==0: if arr[0]==0: print(-1) else: print(1) exit() for i in range(n): if i<=30 and arr[i]>=2**i: print(-1) exit() if n<=30 and arr[n]>2**n: print(-1) exit() maxs=[0]*(n+1) maxs[0]=1 for i in range(1,n): maxs[i]=2*maxs[i-1]-...
n=int(input()) arr=list(map(int,input().split())) ans=sum(arr) if n==0: if arr[0]==1: print(1) else: print(-1) exit() for i in range(n): if i<=30 and arr[i]>=2**i: print(-1) exit() if n<=30 and arr[n]>2**n: print(-1) exit() maxs=[0]*(n+1) maxs[0]=1 for i in range(1,n): maxs[i]=2*maxs[i-1]-...
[["-", 0, 57, 64, 196, 0, 57, 15, 666, 0, 612], ["+", 0, 57, 64, 196, 0, 57, 15, 666, 0, 612], ["-", 0, 1, 0, 652, 3, 4, 0, 664, 17, 33], ["+", 0, 1, 0, 652, 3, 4, 0, 664, 17, 33]]
5
285
#include <algorithm> #include <bitset> #include <iomanip> #include <iostream> #include <list> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; using ll = long long; using vll = vector<long lo...
#include <algorithm> #include <bitset> #include <iomanip> #include <iostream> #include <list> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; using ll = long long; using vll = vector<long lo...
[["-", 0, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["-", 0, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 0, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 0, 57, 15, 339, 51, 16, 12, 69, 28, 22], ["+", 15, 339, 51, 16, 12, 69, 341, 342, 0, 70], ["+", 15, 339, 51, 16, 12, 69, 341, 342, 0, 22], ["+", 15, 339, 51, 16, 12, 69, 341, 342...
1
608
import java.util.Scanner; public class Main { public static void main(String args[]) { Scanner scn = new Scanner(System.in); int n = scn.nextInt(); long[] a = new long[n + 1]; long max = 0; long ne = 1; long ans = 0; for (int i = 0; i <= n; i++) { a[i] = scn.nextLong(); max +...
import java.util.Scanner; public class Main { public static void main(String args[]) { Scanner scn = new Scanner(System.in); int n = scn.nextInt(); long[] a = new long[n + 1]; long max = 0; long ne = 1; long ans = 0; for (int i = 0; i <= n; i++) { a[i] = scn.nextLong(); max +...
[["-", 8, 196, 0, 7, 502, 503, 49, 200, 141, 22], ["+", 8, 196, 0, 7, 502, 503, 49, 200, 141, 22], ["-", 8, 196, 0, 7, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 7, 15, 16, 31, 16, 31, 22], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 17, 47], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 17, 20], ["-", 0, 195, 8, 196, 0, 7, 26, 27, 0, 22...
3
205
N = int(input()) nums = list(map(int, input().split())) nodes = [] currentLeaf = 1 fail = False #check from top for i in range(N + 1): nodes.append(currentLeaf) currentLeaf = (currentLeaf-nums[i])*2 if (currentLeaf < 0): fail = True break if (fail): print(-1) #check from bottom currentLeaf = 0 totalNode = 0 fo...
N = int(input()) nums = list(map(int, input().split())) nodes = [] currentLeaf = 1 fail = False #check from top for i in range(N + 1): nodes.append(currentLeaf) currentLeaf = (currentLeaf-nums[i])*2 if (currentLeaf < 0): fail = True break if (fail): print(-1) else: #check from bottom currentLeaf = 0 tota...
[["+", 36, 36, 0, 656, 0, 57, 75, 76, 0, 95], ["+", 36, 36, 0, 656, 0, 57, 75, 76, 0, 102]]
5
141
#include <algorithm> #include <cstdio> using namespace std; int n, w[101000]; long long C[101000], INF = 1e15, S[101000], res; int main() { int i; scanf("%d", &n); for (i = 0; i <= n; i++) { scanf("%d", &w[i]); } C[0] = 1 - w[0]; for (i = 1; i <= n; i++) { C[i] = min(C[i - 1] * 2 - w[i], INF); } ...
#include <algorithm> #include <cstdio> using namespace std; int n, w[101000]; long long C[101000], INF = 1e15, S[101000], res; int main() { int i; scanf("%d", &n); for (i = 0; i <= n; i++) { scanf("%d", &w[i]); } C[0] = 1 - w[0]; for (i = 1; i <= n; i++) { C[i] = min(C[i - 1] * 2 - w[i], INF); } ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18]]
1
252
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); long[] A = new long[N + 1]; Arrays.setAll(A, i -> sc.nextLong()); long[] S = new long[N + 1]; S[0] = A[N]; for (int i = 1; i <= N; i++) S[i] = ...
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); long[] A = new long[N + 1]; Arrays.setAll(A, i -> sc.nextLong()); long[] S = new long[N + 1]; S[0] = A[N]; for (int i = 1; i <= N; i++) S[i] = ...
[["-", 8, 196, 0, 1, 0, 11, 12, 16, 17, 33], ["-", 0, 1, 0, 11, 12, 16, 12, 504, 516, 22], ["-", 0, 1, 0, 11, 12, 16, 12, 504, 0, 70], ["-", 0, 1, 0, 11, 12, 16, 12, 504, 71, 499], ["-", 0, 1, 0, 11, 12, 16, 12, 504, 0, 73]]
3
267
n,*a=map(int,open(0).read().split()) t=sum(a);v=w=1 for q in a: if(w:=min(2*(w-q),t:=t-q))<0:exit(-1) v+=w print(v)
n,*a=map(int,open(0).read().split());t=sum(a);v=w=1 for q in a: if(w:=min(2*(w-q),t:=t-q))<0:exit(print(-1)) v+=w print(v)
[["+", 36, 36, 36, 36, 36, 36, 0, 656, 0, 35], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 652, 3, 4, 0, 652, 63, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
75
n,*a=map(int,open(0).read().split()) t,v,w=sum(a),1,0 for q in a: w=min(2*(v[-1]-q),t:=t-q) v+=w if w<0:print(-1);exit() print(v)
n,*a=map(int,open(0).read().split()) t,v,w=sum(a),1,1 for q in a: w=min(2*(w-q),t:=t-q) v+=w if w<0:print(-1);exit() print(v)
[["-", 0, 656, 0, 1, 0, 662, 12, 432, 0, 612], ["+", 0, 656, 0, 1, 0, 662, 12, 432, 0, 612], ["-", 0, 657, 12, 23, 0, 657, 31, 206, 51, 22], ["-", 0, 657, 12, 23, 0, 657, 31, 206, 0, 70], ["-", 12, 23, 0, 657, 31, 206, 206, 664, 17, 33], ["-", 12, 23, 0, 657, 31, 206, 206, 664, 28, 612], ["-", 0, 657, 12, 23, 0, 657, 3...
5
84
n = int(input()) A = list(map(int, input().split())) B = [1] for i in range(n): B.append((B[i]-A[i])*2) C = [A[n]] for i, s in enumerate(B): if i == len(B)-1: a = 1 elif B[i] <= 0: print(-1) exit() if B[-1] < 0: print(-1) exit() for i in range(n): C.append(C[i]+A[n-1...
n = int(input()) A = list(map(int, input().split())) B = [1] for i in range(n): B.append((B[i]-A[i])*2) C = [A[n]] for i, s in enumerate(B): if i == len(B)-1: a = 1 elif B[i] <= 0: print(-1) exit() if B[-1]-A[n] < 0: print(-1) exit() for i in range(n): C.append(C[i]+A...
[["+", 0, 656, 0, 57, 15, 666, 0, 657, 17, 33], ["+", 0, 57, 15, 666, 0, 657, 12, 206, 51, 22], ["+", 0, 57, 15, 666, 0, 657, 12, 206, 0, 70], ["+", 0, 57, 15, 666, 0, 657, 12, 206, 206, 22], ["+", 0, 57, 15, 666, 0, 657, 12, 206, 0, 73]]
5
212
n = int(input()) ns = list(map(int, input().split())) li = 1 ans = 0 max_leafs = [1] for i in ns: li = (li - i) * 2 max_leafs.append(li) points = ns.pop() ans += points for i in range(len(ns)-1, -1, -1): a = ns[i] points = min(points + a, max_leafs[i]) ans += points if max_leafs[-1] <= 0: print(...
n = int(input()) ns = list(map(int, input().split())) li = 1 ans = 0 max_leafs = [1] for i in ns: li = (li - i) * 2 max_leafs.append(li) points = ns.pop() ans += points for i in range(len(ns)-1, -1, -1): a = ns[i] points = min(points + a, max_leafs[i]) ans += points if max_leafs[-1] < 0: print(-...
[["-", 36, 36, 0, 656, 0, 57, 15, 666, 667, 19], ["+", 36, 36, 0, 656, 0, 57, 15, 666, 667, 18]]
5
127
#include <bits/stdc++.h> using namespace std; #define repeat(i, a, b) for (int i = (a), _ = (b); i < _; i++) #define repeat_back(i, a, b) for (int i = (b)-1, _ = (a); i >= _; i--) #define mst(a, a0) memset(a, a0, sizeof(a)) //#define vector basic_string #define fi first #define se second #ifndef qwq int cansel_sync = (...
#include <bits/stdc++.h> using namespace std; #define repeat(i, a, b) for (int i = (a), _ = (b); i < _; i++) #define repeat_back(i, a, b) for (int i = (b)-1, _ = (a); i >= _; i--) #define mst(a, a0) memset(a, a0, sizeof(a)) //#define vector basic_string #define fi first #define se second #ifndef qwq int cansel_sync = (...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 19], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 18], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13], ["+", 0, 9, 0, 57, 15, 339, 51, 16, 17, 106], ["+", 0, 57, 15, 339, 51, 16, 12, 23, 0, 24], ["+", 51, 16, 12, 23, 0, 16, 31, 16, 31, 22], ["+", 51, 16, 12, 23, 0, 16, 31, 16, 17,...
1
473
#include <bits/stdc++.h> using namespace std; #define TRACE(x) cerr << #x << " :: " << x << endl #define _ << " " << #define SZ(x) (int)(x).size() #define ALL(x) (x).begin(), (x).end() #define FOR(i, a, b) for (int i = (a); i <= (b); ++i) #define RFOR(i, a, b) for (int i = (a); i >= (b); --i) int main() { ios::sync...
#include <bits/stdc++.h> using namespace std; #define TRACE(x) cerr << #x << " :: " << x << endl #define _ << " " << #define SZ(x) (int)(x).size() #define ALL(x) (x).begin(), (x).end() #define FOR(i, a, b) for (int i = (a); i <= (b); ++i) #define RFOR(i, a, b) for (int i = (a); i >= (b); --i) int main() { ios::sync...
[["+", 8, 9, 0, 43, 49, 50, 51, 16, 17, 72], ["+", 0, 43, 49, 50, 51, 16, 12, 69, 28, 22], ["+", 49, 50, 51, 16, 12, 69, 341, 342, 0, 70], ["+", 49, 50, 51, 16, 12, 69, 341, 342, 0, 13], ["+", 49, 50, 51, 16, 12, 69, 341, 342, 0, 73]]
1
342
#include <algorithm> #include <bitset> #include <cmath> #include <functional> #include <iostream> #include <queue> #include <vector> #define DB cerr << "D" << endl #define pb push_back using namespace std; using ll = long long; using ld = long double; const int INF = 1e9; const ll LINF = 1e18; const double dINF = 1e18;...
#include <algorithm> #include <bitset> #include <cmath> #include <functional> #include <iostream> #include <queue> #include <vector> #define DB cerr << "D" << endl #define pb push_back using namespace std; using ll = long long; using ld = long double; const int INF = 1e9; const ll LINF = 1e18; const double dINF = 1e18;...
[["+", 8, 9, 0, 43, 49, 80, 81, 16, 17, 72], ["+", 8, 9, 0, 43, 49, 80, 81, 16, 12, 13]]
1
388
n = int(input()) a = list(map(int, input().split())) now = 1 allows = [] for i in range(n): ha = a[i] if ha > now: print(-1) exit() allows.append(now - ha) now = (now - ha) * 2 if now < a[n]: print(-1) exit result = a[n] now = a[n] for i in range(n): if now > allows[n-1-i]: ...
n = int(input()) a = list(map(int, input().split())) now = 1 allows = [] for i in range(n): ha = a[i] if ha > now: print(-1) exit() allows.append(now - ha) now = (now - ha) * 2 if now < a[n]: print(-1) exit() result = a[n] now = a[n] for i in range(n): if now > allows[n-1-i]...
[["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
5
151
#include <algorithm> #include <array> #include <bitset> #include <cassert> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <random> #include ...
#include <algorithm> #include <array> #include <bitset> #include <cassert> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <random> #include ...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 79], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22], ["-", 0, 9, 0, 57, 15, 339, 51, 16, 17, 98], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 19], ["+", 0, 9, 0, 57, 15, 339, 51, 16, 17, 18]]
1
250
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define prtd(var, i) cout << fixed << setprecision(i) << var << endl; #define ll long long #define maxn 100005 using namespace std; #define INF 1000000000000000LL ll A[maxn]; ll lim[maxn]; int main() { int n; cin >> n; rep(i, n + 1) cin >>...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define prtd(var, i) cout << fixed << setprecision(i) << var << endl; #define ll long long #define maxn 100005 using namespace std; #define INF 1000000000000000000LL ll A[maxn]; ll lim[maxn]; int main() { int n; cin >> n; rep(i, n + 1) cin...
[["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["-", 0, 14, 8, 9, 0, 7, 26, 27, 17, 29], ["+", 0, 14, 8, 9, 0, 7, 26, 27, 17, 68]]
1
232
N = int(input()) A = [int(i) for i in input().split()] total = sum(A) node = 1 ans = 0 for i in range(N+1): ans += node total -= A[i] #print(node, total) node = min(total, (node - A[i]) * 2) if node < 0: print(-1) print(ans)
N = int(input()) A = [int(i) for i in input().split()] total = sum(A) node = 1 ans = 0 for i in range(N+1): ans += node total -= A[i] #print(node, total) node = min(total, (node - A[i]) * 2) if node < 0: print(-1) exit() print(ans)
[["+", 0, 57, 64, 196, 0, 1, 0, 652, 63, 22], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
5
89
import math #import numpy as np import queue from collections import deque,defaultdict import heapq from sys import stdin,setrecursionlimit #from scipy.sparse.csgraph import dijkstra #from scipy.sparse import csr_matrix ipt = stdin.readline setrecursionlimit(10**7) def main(): n = int(ipt()) a = [int(i) for i ...
import math #import numpy as np import queue from collections import deque,defaultdict import heapq from sys import stdin,setrecursionlimit #from scipy.sparse.csgraph import dijkstra #from scipy.sparse import csr_matrix ipt = stdin.readline setrecursionlimit(10**7) def main(): n = int(ipt()) a = [int(i) for i ...
[["-", 8, 196, 0, 1, 0, 662, 12, 206, 51, 22], ["-", 8, 196, 0, 1, 0, 662, 12, 206, 0, 70], ["-", 8, 196, 0, 1, 0, 662, 12, 206, 0, 73]]
5
147
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll N; cin >> N; vector<ll> A(N + 10); ll sum = 0; for (int i = 0; i <= N; i++) { cin >> A[i]; sum += A[i]; } ll cur = 1; ll ans = 0; for (int i = 0; i <= N; i++) { cur -= A[i]; if (cur < 0) { ans...
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll N; cin >> N; vector<ll> A(N + 10); ll sum = 0; for (int i = 0; i <= N; i++) { cin >> A[i]; sum += A[i]; } ll cur = 1; ll ans = 1; for (int i = 0; i <= N; i++) { cur -= A[i]; if (cur < 0) { ans...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["-", 0, 14, 8, 9, 0, 1, 0, 27, 28, 22], ["-", 0, 14, 8, 9, 0, 1, 0, 27, 17, 29], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
151
f = 0, n, i, a[100010]; long p = 1, ans = 0, b[100010] = {0}; #define rep(x) for (i = 0; i <= x; i++) main() { scanf("%d", &n); rep(n) scanf("%d", &a[i]); rep(n - 1) b[n - 1 - i] = b[n - i] + a[n - i]; rep(n) { ans += p; p -= a[i]; if (p > 0) break; p <<= 1; p = (p > b[i] ? b[i] : p); ...
f = 0, n, i, a[100010]; long p = 1, ans = 0, b[100010] = {0}; #define rep(x) for (i = 0; i <= x; i++) main() { scanf("%d", &n); rep(n) scanf("%d", &a[i]); rep(n - 1) b[n - 1 - i] = b[n - i] + a[n - i]; rep(n) { ans += p; p -= a[i]; if (p < 0) break; p <<= 1; p = (p > b[i] ? b[i] : p); ...
[["-", 8, 9, 0, 57, 15, 23, 0, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 17, 18]]
0
169
#include <algorithm> #include <cassert> #include <cmath> #include <fstream> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef pair<ll, ll> P; const ll mod = 1...
#include <algorithm> #include <cassert> #include <cmath> #include <fstream> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef pair<ll, ll> P; const ll mod = 1...
[["-", 0, 57, 15, 339, 51, 16, 12, 103, 0, 104], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 33], ["+", 15, 339, 51, 16, 31, 16, 12, 69, 28, 22], ["+", 51, 16, 31, 16, 12, 69, 341, 342, 0, 70], ["+", 51, 16, 31, 16, 12, 69, 341, 342, 0, 22], ["+", 51, 16, 31, 16, 12, 69, 341, 342, 0, 73]]
1
439
N = int(input()) A = list(map(int, input().split())) B = [0] *(N+1) B[0] = 1 ans = 0 for i in range(1, N+1): B[i] = (B[i-1] - A[i-1])*2 if B[i] <= 0: ans = -1 break if B[N] < A[N]: ans = -1 if ans == 0: check = 0 for j in range(N, 0, -1): check += A[j] if check < B[j]...
N = int(input()) A = list(map(int, input().split())) B = [0] *(N+1) B[0] = 1 ans = 0 for i in range(1, N+1): B[i] = (B[i-1] - A[i-1])*2 if B[i] <= 0: ans = -1 break if B[N] < A[N]: ans = -1 if ans == 0: check = 0 for j in range(N, 0, -1): check += A[j] if check < B[j]...
[["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 21], ["+", 0, 57, 64, 196, 0, 1, 0, 677, 31, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 677, 17, 107], ["+", 0, 57, 64, 196, 0, 1, 0, 677, 12, 612]]
5
186
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> ii; typedef vector<int> vi; typedef vector<ii> vii; #define f first #define s second #define sz(x) (int)x.size() #define all(x) begin(x), end(x) #define rall(x) rbegin(x), rend(x) #define pb push_back #...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> ii; typedef vector<int> vi; typedef vector<ii> vii; #define f first #define s second #define sz(x) (int)x.size() #define all(x) begin(x), end(x) #define rall(x) rbegin(x), rend(x) #define pb push_back #...
[["-", 36, 36, 36, 36, 0, 30, 0, 43, 39, 40], ["+", 36, 36, 36, 36, 0, 30, 0, 43, 39, 78], ["-", 0, 9, 0, 1, 0, 11, 12, 69, 28, 22], ["+", 0, 9, 0, 1, 0, 11, 12, 69, 28, 22]]
1
335
// **** WHEN THE GOING GETS TOUGH, THE TOUGH GETS GOING. **** #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; #define ll long long int #define ull unsigned long long int #define ld long double #define ordered_set ...
// **** WHEN THE GOING GETS TOUGH, THE TOUGH GETS GOING. **** #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; #define ll long long int #define ull unsigned long long int #define ld long double #define ordered_set ...
[["-", 8, 9, 0, 1, 0, 11, 12, 2, 63, 22], ["+", 8, 9, 0, 1, 0, 11, 12, 2, 63, 22], ["-", 0, 11, 12, 2, 3, 4, 0, 74, 51, 13], ["+", 0, 11, 12, 2, 3, 4, 0, 74, 51, 13]]
1
665
N = int(input()) A = list(map(int,input().split())) # その段で使用する枝の数 branches = dict() for idx,a in enumerate(A): if idx == 0: branch = 1-a else: branch = branch * 2 - a if branch <=0: print(-1) quit() branches[idx] = branch # 後ろから葉と枝の数(nodes)を計算していく ans =0 for idx,leaf in enumerate(reversed(A))...
N = int(input()) A = list(map(int,input().split())) # その段で使用する枝の数 branches = dict() for idx,a in enumerate(A): if idx == 0: branch = 1-a else: branch = branch * 2 - a if branch <0: print(-1) quit() branches[idx] = branch # 後ろから葉と枝の数(nodes)を計算していく ans =0 for idx,leaf in enumerate(reversed(A)):...
[["-", 0, 7, 8, 196, 0, 57, 15, 666, 667, 19], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 18]]
5
160
#include <bits/stdc++.h> #define owo(i, a, b) for (int i = (a); i < (b); ++i) #define uwu(i, a, b) for (int i = (a)-1; i >= (b); --i) #define senpai push_back #define ttgl pair<int, int> #define ayaya cout << "ayaya~" << endl using namespace std; using ll = long long; using ld = long double; const ll MOD = 1000000007;...
#include <bits/stdc++.h> #define owo(i, a, b) for (int i = (a); i < (b); ++i) #define uwu(i, a, b) for (int i = (a)-1; i >= (b); --i) #define senpai push_back #define ttgl pair<int, int> #define ayaya cout << "ayaya~" << endl using namespace std; using ll = long long; using ld = long double; const ll MOD = 1000000007;...
[["+", 0, 11, 12, 16, 12, 16, 31, 23, 0, 24], ["-", 0, 11, 12, 16, 31, 16, 12, 16, 17, 85], ["-", 0, 11, 12, 16, 31, 16, 12, 16, 12, 13], ["+", 12, 16, 31, 23, 0, 16, 12, 23, 0, 25], ["+", 0, 1, 0, 11, 12, 16, 12, 16, 17, 85], ["+", 0, 1, 0, 11, 12, 16, 12, 16, 12, 13]]
1
520
#include <bits/stdc++.h> using namespace std; string s, t; long long ans; int main() { cin >> s; long long cnt = count(s.begin(), s.end(), '1'); for (long long i = 0; i <= cnt; ++i) { ans += (i + 1) / 2; } for (long long i = 0; i < s.size(); ++i) { t += s[i]; long long sz = t.size(); if (sz >=...
#include <bits/stdc++.h> using namespace std; string s, t; long long ans; int main() { cin >> s; long long cnt = count(s.begin(), s.end(), '1'); for (long long i = 0; i <= cnt; ++i) { ans += (i + 1) / 2; } for (long long i = 0; i < s.size(); ++i) { t += s[i]; long long sz = t.size(); if (sz >=...
[["-", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22]]
1
272
#include <bits/stdc++.h> #define ADD(a, b) a = (a + ll(b)) % mod #define MUL(a, b) a = (a * ll(b)) % mod #define MAX(a, b) a = max(a, b) #define MIN(a, b) a = min(a, b) #define rep(i, a, b) for (int i = int(a); i < int(b); i++) #define rer(i, a, b) for (int i = int(a) - 1; i >= int(b); i--) #define all(a) (a).begin(), ...
#include <bits/stdc++.h> #define ADD(a, b) a = (a + ll(b)) % mod #define MUL(a, b) a = (a * ll(b)) % mod #define MAX(a, b) a = max(a, b) #define MIN(a, b) a = min(a, b) #define rep(i, a, b) for (int i = int(a); i < int(b); i++) #define rer(i, a, b) for (int i = int(a) - 1; i >= int(b); i--) #define all(a) (a).begin(), ...
[["+", 12, 16, 31, 16, 12, 16, 31, 23, 0, 24], ["-", 12, 16, 31, 16, 31, 16, 12, 16, 17, 85], ["-", 12, 16, 31, 16, 31, 16, 12, 16, 12, 13], ["+", 12, 16, 31, 23, 0, 16, 12, 23, 0, 25], ["+", 0, 11, 12, 16, 31, 16, 12, 16, 17, 85], ["+", 0, 11, 12, 16, 31, 16, 12, 16, 12, 13]]
1
824
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; #define FOR(i, m, n) for (int i = (m); i < (n); ++i) #define REP(i, n) FOR(i, 0, n) #define ALL(v) (v).begin(), (v).end() using ll = long long; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fLL; const double EPS = 1e-8; const int MOD...
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; #define FOR(i, m, n) for (int i = (m); i < (n); ++i) #define REP(i, n) FOR(i, 0, n) #define ALL(v) (v).begin(), (v).end() using ll = long long; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fLL; const double EPS = 1e-8; const int MOD...
[["-", 75, 76, 0, 9, 0, 1, 0, 27, 28, 22], ["+", 75, 76, 0, 9, 0, 1, 0, 27, 28, 22]]
1
566
// https://atcoder.jp/contests/nomura2020/tasks/nomura2020_e #include <bits/stdc++.h> using namespace std; #define nn 65536 * 4 #define int long long int fullcombo(int x) { int ans = 0; for (int i = 1; i <= x; i++) ans += (i + 1) / 2; return ans; } char str[nn]; int n; vector<int> all; int len[nn], m; names...
// https://atcoder.jp/contests/nomura2020/tasks/nomura2020_e #include <bits/stdc++.h> using namespace std; #define nn 65536 * 4 #define int long long int fullcombo(int x) { int ans = 0; for (int i = 1; i <= x; i++) ans += (i + 1) / 2; return ans; } char str[nn]; int n; vector<int> all; int len[nn], m; names...
[["+", 0, 7, 8, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 27, 17, 29], ["+", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35]]
1
842
#include <algorithm> #include <bitset> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string.h> #include <string> #include <vector> using namespace std; typedef long long ll; typedef long double db; typedef vector<int> vi; typedef pair<...
#include <algorithm> #include <bitset> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string.h> #include <string> #include <vector> using namespace std; typedef long long ll; typedef long double db; typedef vector<int> vi; typedef pair<...
[["-", 64, 1, 0, 11, 12, 23, 0, 16, 31, 22], ["+", 64, 1, 0, 11, 12, 23, 0, 16, 31, 22], ["-", 12, 23, 0, 16, 31, 23, 0, 16, 31, 22], ["+", 12, 23, 0, 16, 31, 23, 0, 16, 31, 22]]
1
560
#include <algorithm> #include <bitset> #include <cassert> #include <ciso646> #include <cmath> #include <complex> #include <cstdio> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include ...
#include <algorithm> #include <bitset> #include <cassert> #include <ciso646> #include <cmath> #include <complex> #include <cstdio> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include ...
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13]]
1
1,094
#include <algorithm> #include <cctype> #include <cmath> #include <cstdio> #include <cstring> #include <functional> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; typedef long long ll; int ma...
#include <algorithm> #include <cctype> #include <cmath> #include <cstdio> #include <cstring> #include <functional> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; typedef long long ll; int ma...
[["+", 0, 14, 8, 9, 0, 1, 0, 16, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 152], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78]]
1
176
import sys input = lambda : sys.stdin.readline().rstrip() sys.setrecursionlimit(max(1000, 10**9)) write = lambda x: sys.stdout.write(x+"\n") t = input() s = t.replace("0", "") q = len(s) # 1の数 n = len(t) ps = [None]*(q+1) c = 0 j = 0 for tmp in t: if tmp=="1": ps[j] = c j += 1 c = 0 els...
import sys input = lambda : sys.stdin.readline().rstrip() sys.setrecursionlimit(max(1000, 10**9)) write = lambda x: sys.stdout.write(x+"\n") t = input() s = t.replace("0", "") q = len(s) # 1の数 n = len(t) ps = [None]*(q+1) c = 0 j = 0 for tmp in t: if tmp=="1": ps[j] = c j += 1 c = 0 els...
[["+", 0, 1, 0, 677, 12, 657, 12, 23, 0, 24], ["+", 0, 1, 0, 677, 12, 657, 12, 23, 0, 25]]
5
593
// #pragma GCC target ("avx") // #pragma GCC optimize("Ofast") // #pragma GCC optimize("unroll-loops") // #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #include <bits/stdc++.h> using namespace std; // #define int long long // #define endl '\n' #pragma region TEMPLATE /* TYPE */ typedef...
// #pragma GCC target ("avx") // #pragma GCC optimize("Ofast") // #pragma GCC optimize("unroll-loops") // #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #include <bits/stdc++.h> using namespace std; // #define int long long // #define endl '\n' #pragma region TEMPLATE /* TYPE */ typedef...
[["-", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13], ["-", 0, 57, 15, 339, 51, 16, 31, 69, 28, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 69, 28, 22], ["-", 0, 57, 15, 339, 51, 16, 12, 103, 0, 104], ["-", 0, 57, 15, 339, 51, 16, 12, 103, 0, 125], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
3,729
T=input() n=len(T) i=r=a=0 for c in T: k=i-r if c=='0': r+=k&1 else: a+=i//2-k//2+(k&1)*(n-i) i+=1 print(a)
T=input() n=len(T) i=r=a=0 for c in T: k=i-r if c=='0': r+=~k&1 else: a+=i//2-k//2+(~k&1)*(n-i) i+=1 print(a)
[["+", 0, 1, 0, 677, 12, 657, 31, 664, 17, 92], ["+", 12, 657, 31, 23, 0, 657, 31, 664, 17, 92]]
5
70
#pragma region Macros #pragma GCC optimize("O3") #include <bits/stdc++.h> #define ll long long #define ld long double #define rep2(i, a, b) for (ll i = a; i <= b; ++i) #define rep(i, n) for (ll i = 0; i < n; ++i) #define rep3(i, a, b) for (ll i = a; i >= b; --i) #define pii pair<int, int> #define pll pair<ll, ll> #def...
#pragma region Macros #pragma GCC optimize("O3") #include <bits/stdc++.h> #define ll long long #define ld long double #define rep2(i, a, b) for (ll i = a; i <= b; ++i) #define rep(i, n) for (ll i = 0; i < n; ++i) #define rep3(i, a, b) for (ll i = a; i >= b; --i) #define pii pair<int, int> #define pll pair<ll, ll> #def...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]]
1
3,011
#include <bits/stdc++.h> #define rep(i, a, ...) \ for (int i = (a) * (strlen(#__VA_ARGS__) != 0); \ i < (int)(strlen(#__VA_ARGS__) ? __VA_ARGS__ : (a)); ++i) #define per(i, a, ...) ...
#include <bits/stdc++.h> #define rep(i, a, ...) \ for (int i = (a) * (strlen(#__VA_ARGS__) != 0); \ i < (int)(strlen(#__VA_ARGS__) ? __VA_ARGS__ : (a)); ++i) #define per(i, a, ...) ...
[["-", 0, 57, 64, 9, 0, 1, 0, 27, 17, 68], ["-", 0, 57, 64, 9, 0, 1, 0, 27, 28, 22], ["-", 75, 76, 0, 57, 64, 9, 0, 1, 0, 35]]
1
930
#pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx") #pragma GCC optimize("unroll-loops") //#pragma warning(disable : 4996) #ifdef _MSC_VER #include <intrin.h> #define __builtin_popcount __popcnt #define __builtin_popcountll __popcnt64 #endif #include <limits.h> #include <ma...
#pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx") #pragma GCC optimize("unroll-loops") //#pragma warning(disable : 4996) #ifdef _MSC_VER #include <intrin.h> #define __builtin_popcount __popcnt #define __builtin_popcountll __popcnt64 #endif #include <limits.h> #include <ma...
[["+", 0, 338, 8, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 338, 8, 9, 0, 1, 0, 27, 17, 29], ["+", 8, 9, 0, 338, 8, 9, 0, 1, 0, 35]]
1
914
#include <bits/stdc++.h> #define endl "\n" using namespace std; typedef long long ll; typedef vector<ll> vl; typedef pair<ll, ll> PP; #define rep(i, n) for (ll i = 0; i < ll(n); i++) #define rrep(i, n) for (ll i = n - 1; i > -1; i--) #define all(v) v.begin(), v.end() #define pb push_back #define fi first #define se sec...
#include <bits/stdc++.h> #define endl "\n" using namespace std; typedef long long ll; typedef vector<ll> vl; typedef pair<ll, ll> PP; #define rep(i, n) for (ll i = 0; i < ll(n); i++) #define rrep(i, n) for (ll i = n - 1; i > -1; i--) #define all(v) v.begin(), v.end() #define pb push_back #define fi first #define se sec...
[["-", 0, 14, 8, 9, 0, 57, 64, 9, 0, 46], ["+", 0, 14, 8, 9, 0, 57, 64, 9, 0, 46]]
1
443
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll n; cin >> n; int i; ll A[n + 1]; for (i = 0; i <= n; i++) cin >> A[i]; ll B[n + 1]; ll ans = 0; B[n] = A[n]; for (i = n - 1; i >= 0; i--) B[i] = B[i + 1] + A[i]; B[0] = 1; for (i = 1; i < n; i++) { B[i]...
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll n; cin >> n; int i; ll A[n + 1]; for (i = 0; i <= n; i++) cin >> A[i]; ll B[n + 1]; ll ans = 0; B[n] = A[n]; for (i = n - 1; i >= 0; i--) B[i] = B[i + 1] + A[i]; B[0] = 1; for (i = 1; i <= n; i++) { B[i...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 12, 2, 3, 4, 0, 16, 12, 23, 0, 24], ["-", 12, 2, 3, 4, 0, 16, 12, 16, 31, 13], ["-", 12, 2, 3, 4, 0, 16, 12, 16, 17, 48], ["+", 12, 2, 3, 4, 0, 16, 12, 23, 0, 25]]
1
216
#include <bits/stdc++.h> const std::int64_t INF = 1e18; int main() { std::int32_t N; std::cin >> N; std::vector<std::int64_t> A(N + 1), B(N + 1); for (std::int32_t i = 0; i <= N; ++i) { std::cin >> A[i]; } // if (N == 0) { // if (A[0] == 1) std::cout << 1 << std::endl; // else std::cout <<...
#include <bits/stdc++.h> const std::int64_t INF = 1e18; int main() { std::int32_t N; std::cin >> N; std::vector<std::int64_t> A(N + 1), B(N + 1); for (std::int32_t i = 0; i <= N; ++i) { std::cin >> A[i]; } // if (N == 0) { // if (A[0] == 1) std::cout << 1 << std::endl; // else std::cout <<...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 0, 57, 15, 339, 51, 16, 12, 69, 28, 22], ["+", 15, 339, 51, 16, 12, 69, 341, 342, 0, 70], ["+", 15, 339, 51, 16, 12, 69, 341, 342, 0, 22], ["+", 15, 339, 51, 16, 12, 69, 341, 342...
1
259
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define ll long long int #define pb push_back #define fi first #define se second #define all(x) x.begin(), x.end() #define mem(x, y) \ memset(x, y, ...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define ll long long int #define pb push_back #define fi first #define se second #define all(x) x.begin(), x.end() #define mem(x, y) \ memset(x, y, ...
[["+", 0, 16, 12, 69, 341, 342, 0, 16, 17, 33], ["+", 0, 16, 12, 69, 341, 342, 0, 16, 12, 13]]
1
468
N = int(input()) A_leaf = list(map(int, input().split())) if N == 0: print(1 if A_leaf[0] == 1 else -1) exit() s = [0]*(N+2) for i in range(1, N+2): s[i] = s[i-1] + A_leaf[i-1] node = [1]*(N+1) for i in range(1, N+1): node[i] = min((node[i-1] - A_leaf[i-1])*2, s[N+1]-s[i]) if node[i] <= A_leaf[i]: ...
N = int(input()) A_leaf = list(map(int, input().split())) if N == 0: print(1 if A_leaf[0] == 1 else -1) exit() s = [0]*(N+2) for i in range(1, N+2): s[i] = s[i-1] + A_leaf[i-1] node = [1]*(N+1) for i in range(1, N+1): node[i] = min((node[i-1] - A_leaf[i-1])*2, s[N+1]-s[i]) if node[i] < A_leaf[i]: ...
[["-", 0, 7, 8, 196, 0, 57, 15, 666, 667, 19], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 18]]
5
176
#include <bits/stdc++.h> #define ll long long #define N 100010 using namespace std; int n, a[N]; ll s[N], ans, no = 1; int main() { cin >> n; for (int i = 0; i <= n; i++) cin >> a[i]; for (int i = n; i >= 0; i--) s[i] = s[i + 1] + a[i]; for (int i = 0; i <= n; i++) { ans += no; no = no - a[i]; ...
#include <bits/stdc++.h> #define ll long long #define N 100010 using namespace std; int n, a[N]; ll s[N], ans, no = 1; int main() { cin >> n; for (int i = 0; i <= n; i++) cin >> a[i]; for (int i = n; i >= 0; i--) s[i] = s[i + 1] + a[i]; for (int i = 0; i <= n; i++) { ans += no; no = no - a[i]; ...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["-", 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, 22]]
1
170
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N, *A=map(int,read().split()) bound = [0]*(N+1) bound[0] = 1 #Nが0のとき if N == 0: if A[0] == 1: print(1) else: print(-1) sys.exit() #Nが0以外のとき #上から for i in range(1,N+1): bound[i] = (b...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N, *A=map(int,read().split()) bound = [0]*(N+1) bound[0] = 1 #Nが0のとき if N == 0: if A[0] == 1: print(1) else: print(-1) sys.exit() #Nが0以外のとき #上から for i in range(1,N+1): bound[i] = (b...
[["-", 0, 7, 8, 196, 0, 57, 15, 666, 667, 19], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 18]]
5
195
#pragma region template 2.4 #include <bits/stdc++.h> using namespace std; template <typename T> using pq_asc = priority_queue<T, vector<T>, greater<T>>; typedef long long ll; typedef vector<ll> vi; typedef vector<vi> vvi; typedef pair<ll, ll> ii; typedef vector<ii> vii; typedef vector<string> vs; #define REP(i, n) for ...
#pragma region template 2.4 #include <bits/stdc++.h> using namespace std; template <typename T> using pq_asc = priority_queue<T, vector<T>, greater<T>>; typedef long long ll; typedef vector<ll> vi; typedef vector<vi> vvi; typedef pair<ll, ll> ii; typedef vector<ii> vii; typedef vector<string> vs; #define REP(i, n) for ...
[["-", 0, 43, 49, 50, 51, 4, 0, 16, 12, 13], ["+", 0, 43, 49, 50, 51, 4, 0, 16, 12, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 25, 0, 35]]
1
591
#include <algorithm> #include <assert.h> #include <bitset> #include <complex> #include <cstring> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using na...
#include <algorithm> #include <assert.h> #include <bitset> #include <complex> #include <cstring> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using na...
[["-", 0, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["-", 0, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 0, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 0, 57, 15, 339, 51, 16, 12, 69, 28, 22], ["+", 15, 339, 51, 16, 12, 69, 341, 342, 0, 70], ["+", 51, 16, 12, 69, 341, 342, 0, 16, 31, 22], ["+", 51, 16, 12, 69, 341, 342, 0, 16, 1...
1
379
#include <iostream> #include <math.h> using namespace std; int main(void) { int N; cin >> N; long long int A[N + 1]; long long int count = 0; for (int i = 0; i < N + 1; i++) { cin >> A[i]; count += A[i]; } long long int ans = count; long long int node = 1; for (int i = 0; i < N + 1; i++) { ...
#include <iostream> #include <math.h> using namespace std; int main(void) { int N; cin >> N; long long int A[N + 1]; long long int count = 0; for (int i = 0; i < N + 1; i++) { cin >> A[i]; count += A[i]; } long long int ans = 0; long long int node = 1; for (int i = 0; i < N + 1; i++) { ans...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 22], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]]
1
161
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <string> #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; typedef long long ll; #define INF 1000000000000000LL int main() { ll N; cin >> N; ll a[N + 1]; ll node = 0; rep(i,...
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <string> #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; typedef long long ll; #define INF 1000000000000000LL int main() { ll N; cin >> N; ll a[N + 1]; ll node = 0; rep(i,...
[["-", 0, 11, 12, 2, 3, 4, 0, 16, 31, 13], ["+", 0, 11, 12, 2, 3, 4, 0, 16, 31, 13], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 72], ["-", 15, 339, 51, 16, 31, 16, 12, 69, 28, 22], ["-", 51, 16, 31, 16, 12, 69, 341, 342, 0, 70], ["-", 51, 16, 31, 16, 12, 69, 341, 342, 0, 22], ["-", 51, 16, 31, 16, 12, 69, 341, 342, 0, 7...
1
239
#include <bits/stdc++.h> // #include <boost/multiprecision/cpp_int.hpp> using namespace std; using ll = long long; // using ll = boost::multiprecision::int128_t; using ld = long double; using V = vector<int>; using Vll = vector<ll>; using Vld = vector<ld>; using Vbo = vector<bool>; using VV = vector<V>; using VVll = ve...
#include <bits/stdc++.h> // #include <boost/multiprecision/cpp_int.hpp> using namespace std; using ll = long long; // using ll = boost::multiprecision::int128_t; using ld = long double; using V = vector<int>; using Vll = vector<ll>; using Vld = vector<ld>; using Vbo = vector<bool>; using VV = vector<V>; using VVll = ve...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
696
t=int(input()) for loopi in range(t): n,a,b,c,d=list(map(int,input().split())) minest=10**40 dd={n:0} while 1: newd={} for i in dd: if i%2: l=int((i-1)/2) if l in newd: newd[l]=min(dd[i]+min(a+d,(i-l)*d),newd[l]) else: newd[l]=dd[i]+min(a+d,(i-l)*d) ...
t=int(input()) for loopi in range(t): n,a,b,c,d=list(map(int,input().split())) minest=10**40 dd={n:0} while 1: newd={} for i in dd: if i%2: l=int((i-1)//2) if l in newd: newd[l]=min(dd[i]+min(a+d,(i-l)*d),newd[l]) else: newd[l]=dd[i]+min(a+d,(i-l)*d) ...
[["-", 0, 662, 12, 652, 3, 4, 0, 657, 17, 85], ["+", 0, 662, 12, 652, 3, 4, 0, 657, 17, 676]]
5
567
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef double db; ll cost[20], n; map<ll, ll> mp; ll beishu[6] = {2, 2, 3, 3, 5, 5}; ll dfs(ll x) { if (x == 0) return 0; if (mp.count(x)) return mp[x]; ll ans = 0x7fffffff; ll ss[6] = {x / 2, x / 2 + 1, x / 3, x / 3 + 1, x / 5, x / 5 ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef double db; ll cost[20], n; map<ll, ll> mp; ll beishu[6] = {2, 2, 3, 3, 5, 5}; ll dfs(ll x) { if (x == 0) return 0; if (mp.count(x)) return mp[x]; ll ans = 0x7fffffffffffffff; ll ss[6] = {x / 2, x / 2 + 1, x / 3, x / 3 + 1, x / 5...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]]
1
298
#include <bits/stdc++.h> #define L 1301281 using namespace std; int T, a, b, c, d; long long n, V, h[L], f[L]; int get(long long x) { int y = x % L; while (h[y] && h[y] ^ x) y = (++y == L) ? 0 : y; return y; } long long calc(long long n) { if (!n) return 0; if (n == 1) return d; int x = get(n); ...
#include <bits/stdc++.h> #define L 1301281 using namespace std; int T, a, b, c, d; long long n, V, h[L], f[L]; int get(long long x) { int y = x % L; while (h[y] && h[y] ^ x) y = (++y == L) ? 0 : y; return y; } long long calc(long long n) { if (!n) return 0; if (n == 1) return d; int x = get(n); ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22]]
1
462
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> using namespace std; #define MAXN 100100 #define ll long long ll n, m, cnt, A, B, C, D, t, ans; map<ll, ll> dp; ll solve(ll u) { if (u == 1) return D; ...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> using namespace std; #define MAXN 100100 #define ll unsigned long long ll n, m, cnt, A, B, C, D, t, ans; map<ll, ll> dp; ll solve(ll u) { if (u == 1) ret...
[["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59]]
1
411
#pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define fs first #define se second #define pi 2 * acos(0) #define PI 3.14159265358979323846264338 typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> pii; typedef pair<ll, ll> pl...
#pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define fs first #define se second #define pi 2 * acos(0) #define PI 3.14159265358979323846264338 typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> pii; typedef pair<ll, ll> pl...
[["+", 8, 9, 0, 1, 0, 11, 12, 2, 63, 22], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 24], ["-", 8, 9, 0, 1, 0, 11, 12, 16, 17, 48], ["-", 8, 9, 0, 1, 0, 11, 12, 16, 12, 22], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 25]]
1
736
// 自己选择的路,跪着也要走完。朋友们,虽然这个世界日益浮躁起来,只 // 要能够为了当时纯粹的梦想和感动坚持努力下去,不管其它人怎么样,我们也 // 能够保持自己的本色走下去。 ——陈立杰 #define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; typedef signed char int8; typedef unsigned char uint8; typedef short int16; typedef unsigned short uint16; typedef i...
// 自己选择的路,跪着也要走完。朋友们,虽然这个世界日益浮躁起来,只 // 要能够为了当时纯粹的梦想和感动坚持努力下去,不管其它人怎么样,我们也 // 能够保持自己的本色走下去。 ——陈立杰 #define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; typedef signed char int8; typedef unsigned char uint8; typedef short int16; typedef unsigned short uint16; typedef i...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22]]
1
733
// SmartCoder #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update using namespace __gnu_pbds; using namespace std; #define sz(a) int((a).size()) #define pb push_back #define mp make_pair #define all(c) (c).begin(), (c)....
// SmartCoder #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update using namespace __gnu_pbds; using namespace std; #define sz(a) int((a).size()) #define pb push_back #define mp make_pair #define all(c) (c).begin(), (c)....
[["+", 8, 9, 0, 1, 0, 2, 63, 118, 28, 22], ["+", 8, 9, 0, 1, 0, 2, 63, 118, 17, 131], ["+", 8, 9, 0, 1, 0, 2, 63, 118, 119, 120], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
1
556
#include <bits/stdc++.h> using namespace std; long long cost[10], n; map<long long, long long> mp; long long dfs(long long x) { if (x == 0) return 0; if (mp.count(x)) return mp[x]; long long ans = 1e18; long long temp[6] = {x / 2, x / 2 + 2, x / 3, x / 3 + 1, x / 5, x / 5 + 1}; long long t[6] = {2, 2,...
#include <bits/stdc++.h> using namespace std; long long cost[10], n; map<long long, long long> mp; long long dfs(long long x) { if (x == 0) return 0; if (mp.count(x)) return mp[x]; long long ans = 1e18; long long temp[6] = {x / 2, x / 2 + 1, x / 3, x / 3 + 1, x / 5, x / 5 + 1}; long long t[6] = {2, 2,...
[["-", 0, 43, 49, 50, 51, 83, 0, 16, 12, 13], ["+", 0, 43, 49, 50, 51, 83, 0, 16, 12, 13]]
1
294
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) constexpr long long INF = (long long)1e18 + 10; int main() { int T; cin >> T; rep(t, T) { long long N; cin >> N; int A, B, C, D; cin >> A >> B >> C >> D; map<long long, int> mp; priority_que...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) constexpr long long INF = (long long)1e18 * 4 + 10; int main() { int T; cin >> T; rep(t, T) { long long N; cin >> N; long long A, B, C, D; cin >> A >> B >> C >> D; map<long long, int> mp; pr...
[["+", 0, 43, 49, 50, 51, 16, 31, 16, 17, 48], ["+", 0, 43, 49, 50, 51, 16, 31, 16, 12, 13], ["-", 8, 9, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["-", 15, 339, 51, 16, 31, 69, 341, 342, 0, 22], ["+", 15, 339, 51, 16, 31, 69, 341, 342, 0, 22], ["-", 0, 1, 0, 11, 31, 69, 341, 342, 0, 22], [...
1
360
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<long long, long long> P; struct edge { long long to, cost; }; const int inf = 1 << 27; const long long INF = 1LL << 60; const int COMBMAX = 1001001; const long long MOD = 1000000007; #define rep(i, n) for (int i = 0; i < (n); ++i) #defin...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<long long, long long> P; struct edge { long long to, cost; }; const int inf = 1 << 27; const long long INF = 1LL << 60; const int COMBMAX = 1001001; const long long MOD = 1000000007; #define rep(i, n) for (int i = 0; i < (n); ++i) #defin...
[["-", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["-", 0, 7, 15, 16, 12, 16, 12, 16, 17, 85], ["-", 0, 7, 15, 16, 12, 16, 12, 16, 12, 13], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
1
749
#include <bits/stdc++.h> #pragma GCC target("avx2") #pragma GCC optimization("O3") #pragma GCC optimization("unroll-loops") #define rep(i, n) for (int i = 0; i < n; ++i) #define REP(i, a, b) for (int i = a; i <= b; ++i) #define filei freopen("input.txt", "r", stdin); #define fileo freopen("output.txt", "w", stdout); #d...
#include <bits/stdc++.h> #pragma GCC target("avx2") #pragma GCC optimization("O3") #pragma GCC optimization("unroll-loops") #define rep(i, n) for (int i = 0; i < n; ++i) #define REP(i, a, b) for (int i = a; i <= b; ++i) #define filei freopen("input.txt", "r", stdin); #define fileo freopen("output.txt", "w", stdout); #d...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 31, 22], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 17, 48], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 12, 22]]
1
3,881
//#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; #define endl '\n' #define lfs cout << fixed << setprecision(10) #define ALL(a) (a).begin(), (a).end() #define ALLR(a) (a).rbegin(), (a).rend() #define spa << " " << #define fi first #define se second #define MP make_pair #define MT make_tuple #def...
//#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; #define endl '\n' #define lfs cout << fixed << setprecision(10) #define ALL(a) (a).begin(), (a).end() #define ALLR(a) (a).rbegin(), (a).rend() #define spa << " " << #define fi first #define se second #define MP make_pair #define MT make_tuple #def...
[["-", 0, 57, 15, 339, 51, 16, 12, 118, 28, 22], ["-", 0, 57, 15, 339, 51, 16, 12, 118, 17, 131], ["-", 0, 57, 15, 339, 51, 16, 12, 118, 119, 120], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22]]
1
1,238
#include <bits/stdc++.h> #define pb push_back #define mp make_pair #define fi first #define se second #define SZ(x) ((int)x.size()) #define FOR(i, a, b) for (int i = a; i <= b; ++i) #define FORD(i, a, b) for (int i = a; i >= b; --i) using namespace std; typedef long long LL; typedef pair<int, int> pa; typedef vector<in...
#include <bits/stdc++.h> #define pb push_back #define mp make_pair #define fi first #define se second #define SZ(x) ((int)x.size()) #define FOR(i, a, b) for (int i = a; i <= b; ++i) #define FORD(i, a, b) for (int i = a; i >= b; --i) using namespace std; typedef long long LL; typedef pair<int, int> pa; typedef vector<in...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22]]
1
499
#include <cstdio> #include <map> #include <queue> #include <set> long long int n; long long int a, b, c, d; std::map<long long int, long long int> codemp; std::set<long long int> chkset; struct st { long long int v, c; bool operator<(const st &r) const { return c > r.c; } }; std::priority_queue<st> pq; long long in...
#include <cstdio> #include <map> #include <queue> #include <set> long long int n; long long int a, b, c, d; std::map<long long int, long long int> codemp; std::set<long long int> chkset; struct st { long long int v, c; bool operator<(const st &r) const { return c > r.c; } }; std::priority_queue<st> pq; long long in...
[["-", 15, 339, 51, 16, 12, 2, 63, 118, 119, 120], ["+", 15, 339, 51, 16, 12, 2, 63, 118, 119, 120], ["-", 15, 339, 51, 16, 12, 2, 3, 4, 0, 22], ["-", 8, 9, 0, 1, 0, 11, 12, 16, 12, 13], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 13]]
1
507
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <vector> #define MOD 1000000007 #define forn(a, n) for (int a = 0; a < (int)(n); ++a) #define dforn(a, n) for (int a = (n)-1; a >= 0; --a) #define foral...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <vector> #define MOD 1000000007 #define forn(a, n) for (int a = 0; a < (int)(n); ++a) #define dforn(a, n) for (int a = (n)-1; a >= 0; --a) #define foral...
[["+", 31, 16, 31, 2, 3, 4, 0, 16, 17, 72], ["+", 31, 16, 31, 2, 3, 4, 0, 16, 12, 13]]
1
503
T = int(input()) for i in range(T): n, A, B, C, D = map(int, input().split()) memo = {} def herasu(N): if N == 0: return 0 if N == 1: return D if N in memo: return memo[N] m = 100000000000000000000000 if N % 2 == 0: ...
T = int(input()) for i in range(T): n, A, B, C, D = map(int, input().split()) memo = {} def herasu(N): if N == 0: return 0 if N == 1: return D if N in memo: return memo[N] m = 100000000000000000000000 if N % 2 == 0: m =...
[["-", 0, 657, 12, 657, 31, 23, 0, 657, 31, 22], ["+", 0, 657, 12, 657, 31, 23, 0, 657, 31, 22], ["-", 31, 23, 0, 657, 12, 23, 0, 657, 31, 22], ["+", 31, 23, 0, 657, 12, 23, 0, 657, 31, 22]]
5
328
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll LINF = 6e18; ll c2, c3, c5, c1; map<ll, ll> mp; ll dfs(ll n) { if (!mp.count(n)) { if (n == 0) { mp[n] = 0; } else if (n == 1) { mp[n] = c1; //} else if (n == 2) { // mp[n] = c1 + min(c1, c2); } else { ...
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll LINF = 6e18; ll c2, c3, c5, c1; map<ll, ll> mp; ll dfs(ll n) { if (!mp.count(n)) { if (n == 0) { mp[n] = 0; } else if (n == 1) { mp[n] = c1; } else { ll res = LINF; if (n <= res / c1) res = min(r...
[["+", 0, 57, 75, 76, 0, 9, 0, 57, 0, 121], ["+", 75, 76, 0, 9, 0, 57, 15, 339, 0, 24], ["+", 0, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 0, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 0, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 75, 76, 0, 9, 0, 57, 15, 339, 0, 25]]
1
346
#include <iostream> #include <map> #include <vector> using namespace std; using cat = long long; cat A, B, C, D, ans; constexpr int MX = 2000000; vector<cat> ans_sm(MX + 1); map<cat, cat> ans_cache; void prec(cat N) { ans_sm[N] = D * N; if (N <= 1) return; cat d3 = N % 3, d5 = N % 5, n3 = N / 3, n5 = N / 5...
#include <iostream> #include <map> #include <vector> using namespace std; using cat = long long; cat A, B, C, D, ans; constexpr int MX = 2000000; vector<cat> ans_sm(MX + 1); map<cat, cat> ans_cache; void prec(cat N) { ans_sm[N] = D * N; if (N <= 1) return; cat d3 = N % 3, d5 = N % 5, n3 = N / 3, n5 = N / 5...
[["+", 0, 11, 31, 69, 341, 342, 0, 16, 17, 72], ["+", 0, 11, 31, 69, 341, 342, 0, 16, 12, 13]]
1
741
def f(k): if k==1:return d if k==0:return 0 if k in m:return m[k] s=min(k*d,f(k//2)+a+k%2*d,f(--k//2)+a+-k%2*d,f(k//3)+b+k%3*d,f(--k//3)+b+-k%3*d,f(k//5)+c+k%5*d,f(--k//5)+c+-k%5*d) m[k]=s return s for _ in range(int(input())): m={} n,a,b,c,d=map(int,input().split()) print(f(n))
def f(k): if k==1:return d if k==0:return 0 if k in m:return m[k] s=min(k*d,f(k//2)+a+k%2*d,f(-(-k//2))+a+-k%2*d,f(k//3)+b+k%3*d,f(-(-k//3))+b+-k%3*d,f(k//5)+c+k%5*d,f(-(-k//5))+c+-k%5*d) m[k]=s return s for _ in range(int(input())): m={} n,a,b,c,d=map(int,input().split()) print(f(n)...
[["+", 31, 652, 3, 4, 0, 664, 28, 23, 0, 24], ["+", 0, 657, 31, 657, 31, 652, 3, 4, 0, 25], ["+", 31, 652, 3, 4, 0, 664, 28, 23, 0, 25]]
5
191
def f(k): if k==1:return d if k==0:return 0 if k in dic:return m[k] s=k*d s=min(s,f(k//2)+a+k%2*d,f((k+1)//2)+a+-k%2*d,f(k//3)+b+k%3*d,f((k+2)//3)+b+-k%3*d,f(k//5)+c+k%5*d,f((k+4)//5)+c+-k%5*d) m[k]=s return s for _ in range(int(input())): m={} n,a,b,c,d=map(int,input().split()) ...
def f(k): if k==1:return d if k==0:return 0 if k in m:return m[k] s=k*d s=min(s,f(k//2)+a+k%2*d,f((k+1)//2)+a+-k%2*d,f(k//3)+b+k%3*d,f((k+2)//3)+b+-k%3*d,f(k//5)+c+k%5*d,f((k+4)//5)+c+-k%5*d) m[k]=s return s for _ in range(int(input())): m={} n,a,b,c,d=map(int,input().split()) pr...
[["-", 0, 14, 8, 196, 0, 57, 15, 666, 0, 22], ["+", 0, 14, 8, 196, 0, 57, 15, 666, 0, 22], ["-", 0, 1, 0, 652, 3, 4, 0, 652, 63, 22], ["+", 0, 1, 0, 652, 3, 4, 0, 652, 63, 22]]
5
200
#include <bits/stdc++.h> using namespace std; typedef long long int ll; const int INF = 1 << 30; const long long LINF = 1LL << 60; const long long MOD = (long long)1e9 + 7; map<ll, ll> memo; ll n, a, b, c, d; ll dfs(ll x) { if (memo.find(x) != end(memo)) { return memo[x]; } if (x <= 1) { return x * d;...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; const int INF = 1 << 30; const long long LINF = 1LL << 60; const long long MOD = (long long)1e9 + 7; map<ll, ll> memo; ll n, a, b, c, d; ll dfs(ll x) { if (memo.find(x) != end(memo)) { return memo[x]; } if (x <= 1) { return x * d;...
[["+", 3, 4, 0, 16, 12, 16, 31, 23, 0, 24], ["+", 0, 16, 12, 16, 31, 23, 0, 16, 31, 22], ["+", 0, 16, 12, 16, 31, 23, 0, 16, 17, 109], ["+", 0, 16, 12, 16, 31, 23, 0, 16, 12, 13], ["+", 3, 4, 0, 16, 12, 16, 31, 23, 0, 25], ["+", 12, 2, 3, 4, 0, 16, 12, 16, 17, 48]]
1
361
#include <algorithm> #include <bitset> #include <cassert> #include <chrono> #include <climits> #include <cmath> #include <cstdlib> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include ...
#include <algorithm> #include <bitset> #include <cassert> #include <chrono> #include <climits> #include <cmath> #include <cstdlib> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include ...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 48], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 85], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
1
791
#define _CRT_SECURE_NO_WARNINGS #include <algorithm> #include <functional> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <string> #include <vector> #define _USE_MATH_DEFINES #include <bitset> #include <deque> #include <iostream> #include <list> #include <map> #include <math.h> #include <queue> #in...
#define _CRT_SECURE_NO_WARNINGS #include <algorithm> #include <functional> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <string> #include <vector> #define _USE_MATH_DEFINES #include <bitset> #include <deque> #include <iostream> #include <list> #include <map> #include <math.h> #include <queue> #in...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13]]
1
846
#include <bits/stdc++.h> using namespace std; using lint = long long int; #define FOR(i, begin, end) \ for (int i = (begin), i##_end_ = (end); i < i##_end_; i++) #define IFOR(i, begin, end) \ for (int i = (end)-1,...
#include <bits/stdc++.h> using namespace std; using lint = long long int; #define FOR(i, begin, end) \ for (int i = (begin), i##_end_ = (end); i < i##_end_; i++) #define IFOR(i, begin, end) \ for (int i = (end)-1,...
[["+", 8, 9, 0, 1, 0, 2, 63, 118, 28, 22], ["+", 8, 9, 0, 1, 0, 2, 63, 118, 17, 131], ["+", 8, 9, 0, 1, 0, 2, 63, 118, 119, 120], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["+", 8, 9, 0, 14, 8, 9, 0, 1, 0, 35]]
1
482
#include <algorithm> #include <cmath> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> #define _repargs(_1, _2, _3, name, ...) name #define _rep(i, n) repi(i, 0, n) #defi...
#include <algorithm> #include <cmath> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> #define _repargs(_1, _2, _3, name, ...) name #define _rep(i, n) repi(i, 0, n) #defi...
[["-", 31, 16, 12, 2, 3, 4, 0, 69, 28, 22], ["+", 31, 16, 12, 2, 3, 4, 0, 69, 28, 22]]
1
711
#include <bits/stdc++.h> using namespace std; long long x[3] = {2, 3, 5}; long long a[3] = {}; long long t, n, d; long long solve(); int main() { cin >> t; while (t--) { cin >> n >> a[0] >> a[1] >> a[2] >> d; cout << solve() << endl; } return 0; } long long solve() { map<long long, long long> mp; ...
#include <bits/stdc++.h> using namespace std; long long x[3] = {2, 3, 5}; long long a[3] = {}; long long t, n, d; long long solve(); int main() { cin >> t; while (t--) { cin >> n >> a[0] >> a[1] >> a[2] >> d; cout << solve() << endl; } return 0; } long long solve() { map<long long, long long> mp; ...
[["-", 0, 30, 0, 14, 8, 9, 0, 37, 0, 13], ["+", 0, 14, 8, 9, 0, 37, 0, 69, 28, 22], ["+", 8, 9, 0, 37, 0, 69, 341, 342, 0, 70], ["+", 8, 9, 0, 37, 0, 69, 341, 342, 0, 13], ["+", 8, 9, 0, 37, 0, 69, 341, 342, 0, 73]]
1
462
#include <bits/stdc++.h> #include <chrono> using namespace std; template <class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } // typedef //------------------------------------------ typedef pair<int, int> PII; typedef unsigned long long LL; typedef pair<LL, LL> PLL; // co...
#include <bits/stdc++.h> #include <chrono> using namespace std; template <class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } // typedef //------------------------------------------ typedef pair<int, int> PII; typedef unsigned long long LL; typedef pair<LL, LL> PLL; // co...
[["+", 0, 16, 31, 23, 0, 16, 31, 16, 12, 13], ["+", 3, 4, 0, 16, 31, 23, 0, 16, 17, 33]]
1
967
T = int(input()) for i in range(T): N,A,B,C,D = map(int,input().split()) memo = {0:0,1:D} def f(n): if n in memo: return memo[n] else: res = D*n r2 = n%2 r3 = n%3 r5 = n%5 res = min(res,f(n//2)+A+r2*D,f(n//3)+B+r3*D,f(n/...
T = int(input()) for i in range(T): N,A,B,C,D = map(int,input().split()) memo = {0:0,1:D} def f(n): if n in memo: return memo[n] else: res = D*n r2 = n%2 r3 = n%3 r5 = n%5 res = min(res,f(n//2)+A+r2*D,f(n//3)+B+r3*D,f(n/...
[["-", 31, 657, 31, 652, 3, 4, 0, 657, 17, 72], ["-", 31, 657, 31, 652, 3, 4, 0, 657, 12, 612]]
5
220
#include <algorithm> #include <bitset> #include <cassert> #include <chrono> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <string> #include <unordered_map> #includ...
#include <algorithm> #include <bitset> #include <cassert> #include <chrono> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <string> #include <unordered_map> #includ...
[["-", 8, 9, 0, 43, 49, 50, 51, 118, 119, 120], ["+", 8, 9, 0, 43, 49, 50, 51, 118, 119, 120]]
1
793
#include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for (int i = (a); i < (b); i++) #define llu unsigned long long #define ll long long ll read() { ll x; if (scanf("%lld", &x) == -1) exit(0); return x; } #define vi vector<int> #define vb vector<bool> const long long INF = 1e18; #define LOCAL_J...
#include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for (int i = (a); i < (b); i++) #define llu unsigned long long #define ll long long ll read() { ll x; if (scanf("%lld", &x) == -1) exit(0); return x; } #define vi vector<int> #define vb vector<bool> const long long INF = 5e18; #define LOCAL_J...
[["-", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["-", 8, 9, 0, 43, 49, 50, 51, 16, 31, 22], ["-", 8, 9, 0, 43, 49, 50, 51, 16, 17, 48], ["-", 8, 9, 0, 43, 49, 50, 51, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 22]]
1
446
#include <algorithm> #include <cmath> #include <complex> #include <deque> #include <iostream> #include <map> #include <random> #include <set> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> #define ft first #define sc second #define pb push_back #define len(v) (int)v.size() #defin...
#include <algorithm> #include <cmath> #include <complex> #include <deque> #include <iostream> #include <map> #include <random> #include <set> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> #define ft first #define sc second #define pb push_back #define len(v) (int)v.size() #defin...
[["+", 0, 11, 12, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 11, 12, 2, 3, 4, 0, 16, 12, 13]]
1
472
#include <bits/stdc++.h> using namespace std; struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); } } fast; long long mod = 998244353; #define REP(i, n) for (long long i = 0; i < (n); i++) long long modpow(long long m, long long n) { if (n == 0) ret...
#include <bits/stdc++.h> using namespace std; struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); } } fast; long long mod = 998244353; #define REP(i, n) for (long long i = 0; i < (n); i++) long long modpow(long long m, long long n) { if (n == 0) ret...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47]]
1
676
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; #define endl '\n' #define all(x) (x).begin(), (x).end() const int INF = 500 + 5; const int N = 4000 + 5; const ll oo = 1e18 + 5; const ll mod = 998244353; int t; ll n; int a, b, c, d; map<ll, ll> maps; vector<int> muls ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; #define endl '\n' #define all(x) (x).begin(), (x).end() const int INF = 500 + 5; const int N = 4000 + 5; const ll oo = 1e18 + 5; const ll mod = 998244353; int t; ll n; int a, b, c, d; map<ll, ll> maps; vector<int> muls ...
[["+", 8, 9, 0, 1, 0, 2, 63, 118, 28, 22], ["+", 8, 9, 0, 1, 0, 2, 63, 118, 17, 131], ["+", 8, 9, 0, 1, 0, 2, 63, 118, 119, 120], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
383
#include <bits/stdc++.h> using namespace std; typedef long long ll; template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } ll N, A, B, C, D; ll hoge[] = {2, 3...
#include <bits/stdc++.h> using namespace std; typedef unsigned long long ll; template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } ll N, A, B, C, D; ll hoge[...
[["+", 36, 36, 0, 30, 0, 134, 39, 86, 0, 87], ["-", 0, 16, 31, 16, 12, 16, 12, 2, 63, 22]]
1
351
T=int(input()) for i in range(T): N,a,b,c,d=map(int, input().split()) memo={} memo[0]=0 memo[1]=d def f(n): if n in memo: return memo[n] e2,e3,e5=n%2,n%3,n%5 dd=min(d*n,d*2+a+f((n-e2)//2),d*2+a+f((n+e2)//2),d*e3+b+f((n-e3)//3),d*(3-e3)+b+f((n+3-e3)//3),d*e5+c+f((n-e5)//5),d*(5-e5)+c+f((n+...
T=int(input()) for i in range(T): N,a,b,c,d=map(int, input().split()) memo={} memo[0]=0 memo[1]=d def f(n): if n in memo: return memo[n] e2,e3,e5=n%2,n%3,n%5 dd=min(d*n,d*e2+a+f((n-e2)//2),d*e2+a+f((n+e2)//2),d*e3+b+f((n-e3)//3),d*(3-e3)+b+f((n+3-e3)//3),d*e5+c+f((n-e5)//5),d*(5-e5)+c+f((...
[["-", 3, 4, 0, 657, 31, 657, 31, 657, 12, 612], ["+", 3, 4, 0, 657, 31, 657, 31, 657, 12, 22], ["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 22]]
5
224
from heapq import heappop,heappush from collections import defaultdict t = int(input()) for i in range(t): n,a,b,c,d=map(int,input().split()) q=[(0,n)] memo = defaultdict(int) while q: s,p = heappop(q) if memo[p]: continue memo[p] = 1 if p == 0: print(s) return heappush(q,(...
from heapq import heappop,heappush from collections import defaultdict t = int(input()) for i in range(t): n,a,b,c,d=map(int,input().split()) q=[(0,n)] memo = defaultdict(int) while q: s,p = heappop(q) if memo[p]: continue memo[p] = 1 if p == 0: print(s) break heappush(q,(s...
[["-", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94]]
5
302
t = int(input()) for _ in range(t): n, a, b, c, d = map(int, input().split()) memo = {} def f(n): if n == 0: return 0 if n == 1: return d if n in memo: return memo[n] m2 = n % 2 m3 = n % 3 m5 = n % 5 ret = min( d * n, d * m2 + a + f((n - m2) // 2), ...
t = int(input()) for _ in range(t): n, a, b, c, d = map(int, input().split()) memo = {} def f(n): if n == 0: return 0 if n == 1: return d if n in memo: return memo[n] m2 = n % 2 m3 = n % 3 m5 = n % 5 ret = min( d * n, d * m2 + a + f((n - m2) // 2), ...
[["-", 31, 657, 31, 657, 12, 23, 0, 657, 31, 612], ["+", 31, 657, 31, 657, 12, 23, 0, 657, 31, 612], ["-", 31, 657, 31, 657, 12, 23, 0, 657, 12, 22], ["+", 31, 657, 31, 657, 12, 23, 0, 657, 12, 22]]
5
225
#include <bits/stdc++.h> using namespace std; template <typename T> void chmin(T &a, T b) { if (a > b) a = b; } using ll = long long; const long long LINF = 1e18; ll v[3] = {2, 3, 5}, w[3], d, n, t; map<ll, ll> m; ll f(ll x) { if (!x) return LINF; if (x == 1) return d; if (m[x]) return m[x]; ...
#include <bits/stdc++.h> using namespace std; template <typename T> void chmin(T &a, T b) { if (a > b) a = b; } using ll = long long; const long long LINF = 1e18; ll v[3] = {2, 3, 5}, w[3], d, n, t; map<ll, ll> m; ll f(ll x) { if (!x) return LINF; if (x == 1) return d; if (m[x]) return m[x]; ...
[["+", 0, 16, 31, 16, 31, 2, 3, 4, 0, 25], ["-", 0, 2, 3, 4, 0, 2, 3, 4, 0, 25]]
1
294
def solve(N, A, B, C, D): d = {0:0, 1:D} s = set() return dfs(N, A, B, C, D, d, s) def dfs(n, A, B, C, D, d, s): if n in d: return d[n] if n in s: return float('inf') s.add(n) ans = float('inf') p = n % 2 if p == 0: ans = min(ans, dfs(n // 2, A, B, ...
def solve(N, A, B, C, D): d = {0:0, 1:D} s = set() return dfs(N, A, B, C, D, d, s) def dfs(n, A, B, C, D, d, s): if n in d: return d[n] if n in s: return float('inf') s.add(n) ans = float('inf') p = n % 2 if p == 0: ans = min(ans, dfs(n // 2, A, B, ...
[["+", 31, 652, 3, 4, 0, 657, 31, 23, 0, 24], ["+", 0, 657, 31, 23, 0, 657, 12, 23, 0, 25], ["+", 31, 657, 31, 652, 3, 4, 0, 657, 17, 676], ["+", 31, 657, 31, 652, 3, 4, 0, 657, 12, 612]]
5
522
#include <algorithm> #include <bitset> #include <cassert> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <unordered_map> #include <unordered_set> #include <vector> #define FOR(i, n, m) for (ll i = n; i < (int)m; i++) #define REP(i, n) FO...
#include <algorithm> #include <bitset> #include <cassert> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <unordered_map> #include <unordered_set> #include <vector> #define FOR(i, n, m) for (ll i = n; i < (int)m; i++) #define REP(i, n) FO...
[["+", 8, 9, 0, 1, 0, 2, 63, 118, 28, 22], ["+", 8, 9, 0, 1, 0, 2, 63, 118, 17, 131], ["+", 8, 9, 0, 1, 0, 2, 63, 118, 119, 120], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["+", 8, 9, 0, 14, 8, 9, 0, 1, 0, 35]]
1
1,658
#include <bits/stdc++.h> using namespace std; #define ALL(x) x.begin(), x.end() #define rep(i, n) for (int i = 0; i < (n); i++) #define debug(v) \ cout << #v << ":"; \ for (auto x : v) { ...
#include <bits/stdc++.h> using namespace std; #define ALL(x) x.begin(), x.end() #define rep(i, n) for (int i = 0; i < (n); i++) #define debug(v) \ cout << #v << ":"; \ for (auto x : v) { ...
[["-", 0, 43, 49, 50, 51, 16, 31, 74, 51, 13], ["+", 0, 43, 49, 50, 51, 16, 31, 74, 51, 22], ["-", 8, 9, 0, 43, 49, 50, 51, 16, 12, 22], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 12, 22]]
1
658
#from collections import defaultdict #from pprint import pprint #from collections import deque #from collections import Counter #from copy import deepcopy #from itertools #import sys #sys.setrecursionlimit(N) #N回まで再起を許可する。 #import numpy as np #import math # = map(int,input().split()) # = list(map(int,input().split()...
#from collections import defaultdict #from pprint import pprint #from collections import deque #from collections import Counter #from copy import deepcopy #from itertools #import sys #sys.setrecursionlimit(N) #N回まで再起を許可する。 #import numpy as np #import math # = map(int,input().split()) # = list(map(int,input().split()...
[["-", 0, 657, 12, 652, 3, 4, 0, 657, 17, 85], ["+", 0, 657, 12, 652, 3, 4, 0, 657, 17, 676]]
5
319
from functools import lru_cache T = int(input()) caseList = [] for i in range(T): caseList.append(list(map(int, input().split()))) @lru_cache(maxsize=None) def solve(n, A, B, C, D): if n == 0: return 0 if n == 1: return D if n == 2: return min(D + D, A + D) ans = n * D ...
from functools import lru_cache T = int(input()) caseList = [] for i in range(T): caseList.append(list(map(int, input().split()))) @lru_cache(maxsize=None) def solve(n, A, B, C, D): if n == 0: return 0 if n == 1: return D if n == 2: return min(D + D, A + D) ans = n * D ...
[["-", 3, 4, 0, 657, 31, 657, 31, 652, 63, 22], ["+", 3, 4, 0, 657, 31, 657, 31, 652, 63, 22]]
5
229
#include <algorithm> #include <climits> #include <cmath> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define ll long long int #define rep(i, n) fo...
#include <algorithm> #include <climits> #include <cmath> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; #define ll long long int #define rep(i, n) fo...
[["-", 0, 16, 12, 23, 0, 16, 12, 69, 28, 22], ["+", 0, 16, 12, 23, 0, 16, 12, 69, 28, 22]]
1
610
#include <bits/stdc++.h> using namespace std; const int N = 3e5; int n; int a[N], h[N], x[N], y[N], g[N]; int ans; void upd(int x) { int nx = h[x]; if (!g[x]) nx++; if (x - n >= 1) if (h[x - n] > nx) h[x - n] = nx, upd(x - n); if (x + n <= n * n) if (h[x + n] > nx) h[x + n] = nx, upd(...
#include <bits/stdc++.h> using namespace std; const int N = 3e5; int n; int a[N], h[N], x[N], y[N], g[N]; int ans; void upd(int x) { int nx = h[x]; if (!g[x]) nx++; if (x - n >= 1) if (h[x - n] > nx) h[x - n] = nx, upd(x - n); if (x + n <= n * n) if (h[x + n] > nx) h[x + n] = nx, upd(...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
409
#include <bits/stdc++.h> #include <iostream> #include <queue> using namespace std; int main() { int n; int dp[500][500]; int x; int y; cin >> n; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { x = min(i, j); y = min(n - i - 1, n - j - 1); dp[j][i] = min(x, y); } } ...
#include <bits/stdc++.h> #include <iostream> #include <queue> using namespace std; int main() { int n; int dp[500][500]; int x; int y; cin >> n; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { x = min(i, j); y = min(n - i - 1, n - j - 1); dp[j][i] = min(x, y); } } ...
[["+", 0, 7, 8, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 27, 17, 68], ["+", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35]]
1
466
// May this submission get accepted #include <bits/stdc++.h> // エイリアス using ll = long signed long; using ull = long unsigned long; using ld = long double; using namespace std; // AtCoder/Codeforces 用 デバッグ検知 #ifdef ONLINE_JUDGE constexpr bool DEBUG_MODE = false; #else constexpr bool DEBUG_MODE = true; #endif // エイリアス...
// May this submission get accepted #include <bits/stdc++.h> // エイリアス using ll = long signed long; using ull = long unsigned long; using ld = long double; using namespace std; // AtCoder/Codeforces 用 デバッグ検知 #ifdef ONLINE_JUDGE constexpr bool DEBUG_MODE = false; #else constexpr bool DEBUG_MODE = true; #endif // エイリアス...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 33], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 72]]
1
1,404