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
import numpy as np A, B, M = map(int,input().split()) a = np.array([int(num) for num in input().split()]) a_min = np.min(a) b = np.array([int(num) for num in input().split()]) b_min = np.min(b) total_min= a_min + b_min for i in range(0, M): x, y, c = map(int,input().split()) min_can = a[x-1] + b[y-1] -c i...
import numpy as np A, B, M = map(int,input().split()) a = np.array([int(num) for num in input().split()]) a_min = np.min(a) b = np.array([int(num) for num in input().split()]) b_min = np.min(b) total_min= a_min + b_min for i in range(0, M): x, y, c = map(int,input().split()) min_can = a[x-1] + b[y-1] -c i...
[["-", 0, 57, 64, 196, 0, 1, 0, 662, 31, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 31, 22]]
5
146
#include <bits/stdc++.h> #define loop(i, a, b) for (int i = a; i < b; i++) #define rep(i, a) loop(i, 0, a) using namespace std; template <class T> using vec = std::vector<T>; typedef long long ll; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } tem...
#include <bits/stdc++.h> #define loop(i, a, b) for (int i = a; i < b; i++) #define rep(i, a) loop(i, 0, a) using namespace std; template <class T> using vec = std::vector<T>; typedef long long ll; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } tem...
[["+", 31, 16, 31, 69, 341, 342, 0, 16, 17, 33], ["+", 31, 16, 31, 69, 341, 342, 0, 16, 12, 13], ["+", 31, 16, 12, 69, 341, 342, 0, 16, 17, 33], ["+", 31, 16, 12, 69, 341, 342, 0, 16, 12, 13]]
1
313
A, B, M = [int(i) for i in input().split()] a_i = [int(i) for i in input().split()] b_i = [int(i) for i in input().split()] m_i = [[int(j) for j in input().split()] for i in range(M)] min_v = 10^5 for m in m_i: v = a_i[m[0]-1] + b_i[m[1]-1] - m[2] if v < min_v: min_v = v min_pair = min(a_i) + min(b_...
A, B, M = [int(i) for i in input().split()] a_i = [int(i) for i in input().split()] b_i = [int(i) for i in input().split()] m_i = [[int(j) for j in input().split()] for i in range(M)] min_v = 10**6 for m in m_i: v = a_i[m[0]-1] + b_i[m[1]-1] - m[2] if v < min_v: min_v = v min_pair = min(a_i) + min(b...
[["-", 0, 656, 0, 1, 0, 662, 12, 657, 17, 140], ["-", 0, 656, 0, 1, 0, 662, 12, 657, 12, 612], ["+", 0, 656, 0, 1, 0, 662, 12, 657, 17, 578], ["+", 0, 656, 0, 1, 0, 662, 12, 657, 12, 612]]
5
152
#include <bits/stdc++.h> using namespace std; // Order statistics tree (if supported by judge!): // #include <ext/pb_ds/assoc_container.hpp> // #include <ext/pb_ds/tree_policy.hpp> // using namespace __gnu_pbds; // template<class TK, class TM> using order_tree = tree<TK, TM, less<TK>, // rb_tree_tag, tree_order_stati...
#include <bits/stdc++.h> using namespace std; // Order statistics tree (if supported by judge!): // #include <ext/pb_ds/assoc_container.hpp> // #include <ext/pb_ds/tree_policy.hpp> // using namespace __gnu_pbds; // template<class TK, class TM> using order_tree = tree<TK, TM, less<TK>, // rb_tree_tag, tree_order_stati...
[["-", 31, 16, 12, 69, 341, 342, 0, 16, 31, 22], ["+", 31, 16, 12, 69, 341, 342, 0, 16, 31, 22]]
1
515
A, B, M = map(int, input().split()) ref = list(map(int, input().split())) mic = list(map(int, input().split())) coupons = [ list(map(int, input().split())) for i in range(M)] ans = min(ref) + min(mic) for i in coupons: print(i) price = ref[i[0]-1] + mic[i[1]-1] - i[2] if price < ans: ans = price print(ans)
A, B, M = map(int, input().split()) ref = list(map(int, input().split())) mic = list(map(int, input().split())) coupons = [ list(map(int, input().split())) for i in range(M)] ans = min(ref) + min(mic) for i in coupons: price = ref[i[0]-1] + mic[i[1]-1] - i[2] if price < ans: ans = price print(ans)
[["-", 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
136
#include <bits/stdc++.h> #define int long long using namespace std; const int N = 1e6 + 10; int A, B, m; int a[N], b[N]; int ans; signed main() { ans = -1e9; cin >> A >> B >> m; int ans2 = 1e9; int ans3 = 1e9; for (int i = 1; i <= A; i++) { cin >> a[i]; ans2 = min(ans2, a[i]); } for (int i = 1; i...
#include <bits/stdc++.h> #define int long long using namespace std; const int N = 1e6 + 10; int A, B, m; int a[N], b[N]; int ans; signed main() { ans = 1e9; cin >> A >> B >> m; int ans2 = 1e9; int ans3 = 1e9; for (int i = 1; i <= A; i++) { cin >> a[i]; ans2 = min(ans2, a[i]); } for (int i = 1; i ...
[["-", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13], ["-", 8, 9, 0, 1, 0, 11, 12, 2, 63, 22], ["+", 8, 9, 0, 1, 0, 11, 12, 2, 63, 22]]
1
202
a,b,m=map(int,input().split()) A=list(map(int,input().split())) B=list(map(int,input().split())) lst=[] for i in range(m): x,y,c=map(int,input().split()) lst.append([x,y,c]) v=min(A)+min(B) for i in range(m): V=a[A[i][0]-1]+B[lst[i][1]-1]-lst[i][2] if v>V: v=V print(v)
a,b,m=map(int,input().split()) A=list(map(int,input().split())) B=list(map(int,input().split())) lst=[] for i in range(m): x,y,c=map(int,input().split()) lst.append([x,y,c]) v=min(A)+min(B) for i in range(m): V=A[lst[i][0]-1]+B[lst[i][1]-1]-lst[i][2] if v>V: v=V print(v)
[["-", 0, 662, 12, 657, 31, 657, 31, 206, 51, 22], ["-", 0, 662, 12, 657, 31, 657, 31, 206, 0, 70], ["+", 0, 662, 12, 657, 31, 657, 31, 206, 0, 70], ["+", 31, 206, 206, 657, 31, 206, 51, 206, 51, 22]]
5
160
#include <bits/stdc++.h> using namespace std; const int maxi = 1e6 + 10; int a[maxi], b[maxi]; int n, m, x; string s; int main() { cin >> n >> m >> x; for (int i = 1; i <= n; i++) scanf("%d", &a[i]); for (int j = 1; j <= m; j++) scanf("%d", &b[j]); int ans = a[1] + b[1]; for (int i = 1; i <= x;...
#include <bits/stdc++.h> using namespace std; const int maxi = 1e6 + 10; int a[maxi], b[maxi]; int n, m, x; string s; int main() { cin >> n >> m >> x; for (int i = 1; i <= n; i++) scanf("%d", &a[i]); for (int j = 1; j <= m; j++) scanf("%d", &b[j]); int ans = a[1] + b[1]; for (int i = 1; i <= x;...
[["-", 3, 4, 0, 16, 31, 16, 12, 69, 28, 22], ["+", 3, 4, 0, 16, 31, 16, 12, 69, 28, 22]]
1
228
#include <bits/stdc++.h> using namespace std; typedef int64_t ll; typedef long double ld; const ll MOD = 1000000007; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define change(a, b) \ do { ...
#include <bits/stdc++.h> using namespace std; typedef int64_t ll; typedef long double ld; const ll MOD = 1000000007; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define change(a, b) \ do { ...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22]]
1
336
a, b, m = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) aa = sorted(a) bb = sorted(b) lis = [] mi = 10**12 for i in range(m): x, y, c = map(int, input().split()) s = a[x-1]+b[y-1]-c mi = min(s, mi) mii = a[0]+b[0] ans = min(mii,mi) print(ans)
a, b, m = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) aa = sorted(a) bb = sorted(b) lis = [] mi = 10**12 for i in range(m): x, y, c = map(int, input().split()) s = a[x-1]+b[y-1]-c mi = min(s, mi) mii = aa[0]+bb[0] ans = min(mii,mi) print(ans)
[["-", 0, 1, 0, 662, 12, 657, 31, 206, 51, 22], ["+", 0, 1, 0, 662, 12, 657, 31, 206, 51, 22], ["-", 0, 1, 0, 662, 12, 657, 12, 206, 51, 22], ["+", 0, 1, 0, 662, 12, 657, 12, 206, 51, 22]]
5
147
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll a[100005], b[100005], c[100005]; ll x[100005], y[100005]; int main(void) { ll A, B, M; scanf("%lld%lld%lld", &A, &B, &M); ll min1 = 100000000000, min2 = 1000000000000; for (ll i = 1; i <= A; i++) { scanf("%lld", &a[i]); min1 = min(mi...
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll a[100005], b[100005], c[100005]; ll x[100005], y[100005]; int main(void) { ll A, B, M; scanf("%lld%lld%lld", &A, &B, &M); ll min1 = 100000000000, min2 = 1000000000000; for (ll i = 1; i <= A; i++) { scanf("%lld", &a[i]); min1 = min(mi...
[["-", 31, 16, 12, 69, 341, 342, 0, 69, 28, 22], ["+", 31, 16, 12, 69, 341, 342, 0, 69, 28, 22]]
1
253
A,B,M = map(int,input().split()) a = list(map(int,input().split())) b = list(map(int,input().split())) discount = [] for i in [0]*M: discount.append(list(map(int,input().split()))) min_comb = min(a)+min(b) for i in range(M): min_comb = min(min_comb,a[discount[i][0]-1]+b[discount[i][1]-1]-discount[i][2]) ans...
A,B,M = map(int,input().split()) a = list(map(int,input().split())) b = list(map(int,input().split())) discount = [] for i in [0]*M: discount.append(list(map(int,input().split()))) min_comb = min(a)+min(b) for i in range(M): min_comb = min(min_comb,a[discount[i][0]-1]+b[discount[i][1]-1]-discount[i][2]) ans...
[["-", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 12, 22]]
5
151
A, B, M = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) xyc = [tuple(map(int, input().split())) for _ in range(M)] minP = min(a) + min(b) for x, y, c in xyc: minP = min(a[x-1]+b[x-1]-c, minP) print(minP)
A, B, M = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) xyc = [tuple(map(int, input().split())) for _ in range(M)] minP = min(a) + min(b) for x, y, c in xyc: minP = min(a[x-1]+b[y-1]-c, minP) print(minP)
[["-", 0, 657, 31, 657, 12, 206, 206, 657, 31, 22], ["+", 0, 657, 31, 657, 12, 206, 206, 657, 31, 22]]
5
124
#include <algorithm> #include <cmath> #include <cstring> #include <iostream> #include <limits> #include <map> #include <queue> #include <set> #include <string> #include <vector> using namespace std; typedef long long int lld; int T; int N, P; int check[1000001]; int A, B, M; vector<int> a; vector<int> b; int m1 = 1e9; ...
#include <algorithm> #include <cmath> #include <cstring> #include <iostream> #include <limits> #include <map> #include <queue> #include <set> #include <string> #include <vector> using namespace std; typedef long long int lld; int T; int N, P; int check[1000001]; int A, B, M; vector<int> a; vector<int> b; int m1 = 1e9; ...
[["-", 31, 16, 12, 69, 341, 342, 0, 16, 31, 22], ["+", 31, 16, 12, 69, 341, 342, 0, 16, 31, 22]]
1
247
/* Code by pedroslrey * * march 8 * * Sunday */ #include <bits/stdc++.h> using namespace std; using lli = long long int; const int INF = 1000000007; const lli LLINF = 9223372036854775800; #define debug(args...) fprintf(stderr, args) #define show(x) fprintf(stderr, "[DEBUG] -> %d\n", x) in...
/* Code by pedroslrey * * march 8 * * Sunday */ #include <bits/stdc++.h> using namespace std; using lli = long long int; const int INF = 1000000007; const lli LLINF = 9223372036854775800; #define debug(args...) fprintf(stderr, args) #define show(x) fprintf(stderr, "[DEBUG] -> %d\n", x) in...
[["-", 31, 16, 12, 69, 341, 342, 0, 16, 31, 22], ["+", 31, 16, 12, 69, 341, 342, 0, 16, 31, 22]]
1
277
#include <algorithm> #include <cstdio> using namespace std; const int N = 100'009; int a[N]; int b[N]; int main() { int na, nb, m; scanf("%d%d%d", &na, &nb, &m); int mna = 1'000'000'000; for (int i = 0; i < na; ++i) { scanf("%d", a + i); mna = min(mna, a[i]); } int mnb = 1'000'000'000; for (in...
#include <algorithm> #include <cstdio> using namespace std; const int N = 100'009; int a[N]; int b[N]; int main() { int na, nb, m; scanf("%d%d%d", &na, &nb, &m); int mna = 1'000'000'000; for (int i = 0; i < na; ++i) { scanf("%d", a + i); mna = min(mna, a[i]); } int mnb = 1'000'000'000; for (in...
[["-", 3, 4, 0, 16, 31, 16, 12, 69, 28, 22], ["+", 3, 4, 0, 16, 31, 16, 12, 69, 28, 22]]
1
224
#B #入力 A,B,M=map(int,input().split()) a=list(map(int,input().split())) b=list(map(int,input().split())) d=[list(map(int,input().split())) for i in range(M)] #処理 x=min(a)+min(b) for i in d: t=a[d[0]-1]+b[d[1]-1]-d[2] if t>x: x=t print(x)
#B #入力 A,B,M=map(int,input().split()) a=list(map(int,input().split())) b=list(map(int,input().split())) d=[list(map(int,input().split())) for i in range(M)] #処理 x=min(a)+min(b) for i in d: t=a[i[0]-1]+b[i[1]-1]-i[2] if t<x: x=t print(x)
[["-", 31, 657, 31, 206, 206, 657, 31, 206, 51, 22], ["+", 31, 657, 31, 206, 206, 657, 31, 206, 51, 22], ["-", 31, 657, 12, 206, 206, 657, 31, 206, 51, 22], ["+", 31, 657, 12, 206, 206, 657, 31, 206, 51, 22], ["-", 0, 1, 0, 662, 12, 657, 12, 206, 51, 22], ["+", 0, 1, 0, 662, 12, 657, 12, 206, 51, 22], ["-", 0, 7, 8, 19...
5
135
A,B,M = map(int,input().split()) a = list(map(int,input().split())) b = list(map(int,input().split())) x = [0] * M y = [0] * M c = [0] * M for i in range(M): x[i], y[i], c[i] = map(int, input().split()) ans= 0 tmp =0 #割引券を使わない場合 ans = min(a) + min(b) #割引券を使う場合 for i in range(M): if a[x[i]-1] + b[y[i]-1] - c[...
A,B,M = map(int,input().split()) a = list(map(int,input().split())) b = list(map(int,input().split())) x = [0] * M y = [0] * M c = [0] * M for i in range(M): x[i], y[i], c[i] = map(int, input().split()) ans= 0 tmp =0 #割引券を使わない場合 ans = min(a) + min(b) #割引券を使う場合 for i in range(M): if a[x[i]-1] + b[y[i]-1] - c[...
[["+", 12, 657, 31, 657, 31, 206, 206, 657, 17, 33], ["+", 12, 657, 31, 657, 31, 206, 206, 657, 12, 612], ["+", 12, 657, 31, 657, 12, 206, 206, 657, 17, 33], ["+", 12, 657, 31, 657, 12, 206, 206, 657, 12, 612]]
5
189
a,b,m=map(int, input().split()) A=list(map(int, input().split())) B=list(map(int, input().split())) buf=min(A)+min(B) for i in range(m): x,y,c=map(int, input().split()) cp=A[x-1]+B[y-1]-c if buf>=cp: buf==cp print(buf)
a,b,m=map(int, input().split()) A=list(map(int, input().split())) B=list(map(int, input().split())) buf=min(A)+min(B) for i in range(m): x,y,c=map(int, input().split()) cp=A[x-1]+B[y-1]-c if buf>=cp: buf=cp print(buf)
[["-", 0, 57, 64, 196, 0, 1, 0, 666, 667, 60], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 0, 32]]
5
118
na,nb,M=map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) C = [[0 for i in range(3)] for j in range(M)] #C = [[0]*3]*M s=min(A)+min(B) t=0 #print(A) #print(B) for i in range(M): C[i][0],C[i][1],C[i][2] = map(int, input().split()) #print(C) for j in range(M): print(j...
na,nb,M=map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) C = [[0 for i in range(3)] for j in range(M)] #C = [[0]*3]*M s=min(A)+min(B) t=0 #print(A) #print(B) for i in range(M): C[i][0],C[i][1],C[i][2] = map(int, input().split()) #print(C) for j in range(M): #print(...
[["-", 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
194
A, B, M = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) value = min(a) + min(b) for i in range(M): x,y,c = list(map(int, input().split())) if A[x-1] + B[y-1] - c < value: value = A[x-1] + B[y-1] - c print(value)
A, B, M = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) value = min(a) + min(b) for i in range(M): x,y,c = list(map(int, input().split())) if a[x-1] + b[y-1] - c < value: value = a[x-1] + b[y-1] - c print(value)
[["-", 15, 666, 0, 657, 31, 657, 31, 206, 51, 22], ["+", 15, 666, 0, 657, 31, 657, 31, 206, 51, 22], ["-", 15, 666, 0, 657, 31, 657, 12, 206, 51, 22], ["+", 15, 666, 0, 657, 31, 657, 12, 206, 51, 22], ["-", 0, 662, 12, 657, 31, 657, 31, 206, 51, 22], ["+", 0, 662, 12, 657, 31, 657, 31, 206, 51, 22], ["-", 0, 662, 12, 6...
5
132
#include <algorithm> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <string.h> using namespace std; long int A, B, M; long int a[100005], b[100005], x[100005], y[100005], c[100005]; int main() { cin >> A >> B >> M; long a_m = 10000000; long b_m = 10000000; for (long int i ...
#include <algorithm> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <string.h> using namespace std; long int A, B, M; long int a[100005], b[100005], x[100005], y[100005], c[100005]; int main() { cin >> A >> B >> M; long a_m = 10000000; long b_m = 10000000; for (long int i ...
[["-", 0, 11, 12, 2, 3, 4, 0, 69, 28, 22], ["+", 0, 11, 12, 2, 3, 4, 0, 69, 28, 22]]
1
249
#include <bits/stdc++.h> // #include <ext/pb_ds/tree_policy.hpp> // #include <ext/pb_ds/assoc_container.hpp> using namespace std; // using namespace __gnu_pbds; typedef long long ll; typedef long double ld; typedef pair<int, int> pi; typedef pair<ll, ll> pl; typedef pair<double, double> pd; typedef priority_queue<int...
#include <bits/stdc++.h> // #include <ext/pb_ds/tree_policy.hpp> // #include <ext/pb_ds/assoc_container.hpp> using namespace std; // using namespace __gnu_pbds; typedef long long ll; typedef long double ld; typedef pair<int, int> pi; typedef pair<ll, ll> pl; typedef pair<double, double> pd; typedef priority_queue<int...
[["-", 3, 4, 0, 16, 31, 16, 12, 69, 28, 22], ["+", 3, 4, 0, 16, 31, 16, 12, 69, 28, 22]]
1
311
a,b,m=map(int,input().split()) al=list(map(int,input().split())) bl=list(map(int,input().split())) tmp=99999999 for i in range(m): x,y,c=[int(i) for i in input().split()] cost=al[x-1]+bl[y-1]-c #各クーポンを使った時の金額 tmp=min(tmp,cost) k=(min(al)+min(bl)) #割引券を使わなかった時の最小値 print(min(k,cost))
a,b,m=map(int,input().split()) al=list(map(int,input().split())) bl=list(map(int,input().split())) tmp=99999999 for i in range(m): x,y,c=[int(i) for i in input().split()] cost = al[x-1] + bl[y-1] - c #各割引券を使った時の金額 tmp=min(tmp,cost) k=(min(al)+min(bl)) #割引券を使わなかった時の最小値 print(min(k,tmp))
[["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 22]]
5
134
a,b,m=map(int,input().split()) *a,=map(int,input().split()) *b,=map(int,input().split()) mi=10**9 for i in range(m): x,y,c=map(int,input().split()) if len(a)<=x and len(b)<=y: res=a[x-1]+b[y-1]-c mi=min(mi,res) l=min(a)+min(b) print(min(mi,l))
a,b,m=map(int,input().split()) *a,=map(int,input().split()) *b,=map(int,input().split()) ans=10**9 for i in range(m): x,y,c=map(int,input().split()) if len(a)>=x and len(b)>=y: res=a[x-1]+b[y-1]-c ans=min(ans,res) l=min(a)+min(b) print(min(ans,l))
[["-", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["-", 8, 196, 0, 57, 15, 679, 31, 666, 667, 19], ["+", 8, 196, 0, 57, 15, 679, 31, 666, 667, 20], ["-", 8, 196, 0, 57, 15, 679, 12, 666, 667, 19], ["+", 8, 196, 0, 57, 15, 679, 12, 666, 667, 20], ["-", 0, 57, 64, 196, 0, 1, 0, 66...
5
141
#include <iostream> using namespace std; int main() { int A, B, M, a[100], b[100], i, j, m[100], x[100], y[100]; cin >> A >> B >> M; for (i = 1; i <= A; i++) cin >> a[i]; for (i = 1; i <= B; i++) cin >> b[i]; for (i = 1; i <= M; i++) { cin >> x[i] >> y[i] >> m[i]; } int mina = a[1], minb = b[1...
#include <iostream> using namespace std; int main() { int A, B, M, a[100005], b[100005], i, j, m[100005], x[100005], y[100005]; cin >> A >> B >> M; for (i = 1; i <= A; i++) cin >> a[i]; for (i = 1; i <= B; i++) cin >> b[i]; for (i = 1; i <= M; i++) { cin >> x[i] >> y[i] >> m[i]; } int mina = a...
[["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13]]
1
268
#include <bits/stdc++.h> #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 INF 2e9 #define ALL(v) v.begin(), v.end() using namespace std; typedef long long ll; int inputValue() { int a; cin >> a; return a; }; vo...
#include <bits/stdc++.h> #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 INF 2e9 #define ALL(v) v.begin(), v.end() using namespace std; typedef long long ll; int inputValue() { int a; cin >> a; return a; }; vo...
[["-", 31, 16, 12, 69, 341, 342, 0, 16, 31, 22], ["+", 31, 16, 12, 69, 341, 342, 0, 16, 31, 22]]
1
309
AC, BC, MC = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) M = [tuple(map(int, input().split())) for _ in range(MC)] ans = min(A) + min(B) for x, y, c in M: ans = min(ans, A[x - 1] + B[x - 1] - c) print(ans)
AC, BC, MC = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) M = [tuple(map(int, input().split())) for _ in range(MC)] ans = min(A) + min(B) for x, y, c in M: ans = min(ans, A[x - 1] + B[y - 1] - c) print(ans)
[["-", 0, 657, 31, 657, 12, 206, 206, 657, 31, 22], ["+", 0, 657, 31, 657, 12, 206, 206, 657, 31, 22]]
5
124
a,b,m=map(int,input().split()) A=list(map(int,input().split())) B=list(map(int,input().split())) ans=min(A)+min(B) for i in range(m): x,y,c=map(int,input().split()) k=A[x]+B[y]-c if k<ans: ans=k print(ans)
a,b,m=map(int,input().split()) A=list(map(int,input().split())) B=list(map(int,input().split())) ans=min(A)+min(B) for i in range(m): x,y,c=map(int,input().split()) k=A[x-1]+B[y-1]-c if k<ans: ans=k print(ans)
[["+", 12, 657, 31, 657, 31, 206, 206, 657, 17, 33], ["+", 12, 657, 31, 657, 31, 206, 206, 657, 12, 612], ["+", 12, 657, 31, 657, 12, 206, 206, 657, 17, 33], ["+", 12, 657, 31, 657, 12, 206, 206, 657, 12, 612]]
5
114
a,b,m = map(int,input().split()) A = list(map(int,input().split())) B = list(map(int,input().split())) xyc = [list(map(int,input().split())) for _ in range(m)] price = min(A)+min(B) for x,y,c in xyc: k = A[x-1] + B[y-1] - c if k < price: price = k print(k)
a,b,m = map(int,input().split()) A = list(map(int,input().split())) B = list(map(int,input().split())) xyc = [list(map(int,input().split())) for _ in range(m)] price = min(A)+min(B) for x,y,c in xyc: k = A[x-1] + B[y-1] - c if k < price: price = k print(price)
[["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22]]
5
127
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define REP(i, n) for (int i = 1; i <= (n); i++) typedef long long ll; typedef pair<int, int> pii; const int INF = 1e9 + 7; int main() { int a, b, m; cin >> a >> b >> m; vector<int> ref; vector<int> rag; int min_re...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define REP(i, n) for (int i = 1; i <= (n); i++) typedef long long ll; typedef pair<int, int> pii; const int INF = 1e9 + 7; int main() { int a, b, m; cin >> a >> b >> m; vector<int> ref; vector<int> rag; int min_re...
[["-", 31, 16, 31, 69, 341, 342, 0, 16, 31, 22], ["+", 31, 16, 31, 69, 341, 342, 0, 16, 31, 22], ["-", 31, 16, 12, 69, 341, 342, 0, 16, 31, 22], ["+", 31, 16, 12, 69, 341, 342, 0, 16, 31, 22]]
1
216
A, B, M = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) x = [0]*M y = [0]*M c = [0]*M ans = a[0]+b[0] for i in range(M): x[i], y[i], c[i] = map(int, input().split()) if a[x[i]-1] + b[y[i]-1] - c[i] < ans: ans = a[x[i]-1] + b[y[i]-1] - c[i] print(ans...
A, B, M = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) x = [0]*M y = [0]*M c = [0]*M ans = sorted(a)[0]+sorted(b)[0] for i in range(M): x[i], y[i], c[i] = map(int, input().split()) if a[x[i]-1] + b[y[i]-1] - c[i] < ans: ans = a[x[i]-1] + b[y[i]-1] -...
[["+", 0, 662, 12, 657, 31, 206, 51, 652, 63, 22], ["+", 12, 657, 31, 206, 51, 652, 3, 4, 0, 24], ["+", 12, 657, 31, 206, 51, 652, 3, 4, 0, 25], ["+", 0, 662, 12, 657, 12, 206, 51, 652, 63, 22], ["+", 12, 657, 12, 206, 51, 652, 3, 4, 0, 24], ["+", 12, 657, 12, 206, 51, 652, 3, 4, 0, 25]]
5
177
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) typedef long long ll; int main() { cin.tie(0); ios::sync_with_stdio(false); ll A, B, M; cin >> A >> B >> M; vector<ll> va(A), vb(B); ll min_a, min_b; rep(i, A) { cin >> va[i]; if (i == 0) min_a = ...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) typedef long long ll; int main() { cin.tie(0); ios::sync_with_stdio(false); ll A, B, M; cin >> A >> B >> M; vector<ll> va(A), vb(B); ll min_a, min_b; rep(i, A) { cin >> va[i]; if (i == 0) min_a = ...
[["-", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22]]
1
217
#!/usr/bin/env python # coding: utf-8 def ri(): return int(input()) def rl(): return list(input().split()) def rli(): return list(map(int, input().split())) def main(): a, b, m = rli() la = rli() lb = rli() ans = min(la)+min(lb) for i in range(m): x, y, c = rli() x -=...
#!/usr/bin/env python # coding: utf-8 def ri(): return int(input()) def rl(): return list(input().split()) def rli(): return list(map(int, input().split())) def main(): a, b, m = rli() la = rli() lb = rli() ans = min(la)+min(lb) for i in range(m): x, y, c = rli() x -=...
[["-", 3, 4, 0, 657, 31, 657, 12, 206, 206, 22], ["+", 3, 4, 0, 657, 31, 657, 12, 206, 206, 22]]
5
141
from heapq import heappush, heappop, heapify from collections import deque, defaultdict, Counter import itertools from itertools import permutations, combinations, accumulate import sys import bisect import string import math import time def I(): return int(input()) def S(): return input() def MI(): return map(in...
from heapq import heappush, heappop, heapify from collections import deque, defaultdict, Counter import itertools from itertools import permutations, combinations, accumulate import sys import bisect import string import math import time def I(): return int(input()) def S(): return input() def MI(): return map(in...
[["-", 8, 196, 0, 1, 0, 662, 12, 206, 51, 22], ["+", 8, 196, 0, 1, 0, 662, 12, 206, 51, 22]]
5
519
// includes #include <algorithm> #include <assert.h> #include <bitset> #include <cmath> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> #include <unordered_map> #include <vector> template <cl...
// includes #include <algorithm> #include <assert.h> #include <bitset> #include <cmath> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> #include <unordered_map> #include <vector> template <cl...
[["-", 0, 16, 31, 16, 12, 69, 341, 342, 0, 22], ["+", 0, 16, 31, 16, 12, 69, 341, 342, 0, 22]]
1
691
# encoding:utf-8 import copy import random import bisect #bisect_left これで二部探索の大小検索が行える import fractions #最小公倍数などはこっち import math import sys import collections mod = 10**9+7 sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000 d = collections.deque() def LI(): return list(map(int, sys.stdin.readline().split())) A, B, M =...
# encoding:utf-8 import copy import random import bisect #bisect_left これで二部探索の大小検索が行える import fractions #最小公倍数などはこっち import math import sys import collections mod = 10**9+7 sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000 d = collections.deque() def LI(): return list(map(int, sys.stdin.readline().split())) A, B, M =...
[["-", 3, 4, 0, 657, 31, 657, 12, 206, 51, 22], ["+", 3, 4, 0, 657, 31, 657, 12, 206, 51, 22]]
5
189
a,b,m=map(int,input().split()) al=list(map(int,input().split())) bl=list(map(int,input().split())) x=min(al)+min(bl) for i in range(m): x,y,c=map(int,input().split()) t=al[x-1]+bl[y-1]-c x=min(x,t) print(x)
a,b,m=map(int,input().split()) al=list(map(int,input().split())) bl=list(map(int,input().split())) z=min(al)+min(bl) for i in range(m): x,y,c=map(int,input().split()) t=al[x-1]+bl[y-1]-c z=min(z,t) print(z)
[["-", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["-", 0, 7, 8, 196, 0, 1, 0, 662, 31, 22], ["+", 0, 7, 8, 196, 0, 1, 0, 662, 31, 22], ["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["+", 0, 656, 0...
5
118
#!/usr/bin/env python3 a,b,m = map(int,input().split()) a = list(map(int,input().split())) b = list(map(int,input().split())) a_idx = a.index(min(a)) b_idx = b.index(min(b)) #print(a_idx,b_idx) ans = min(a)+min(b) for i in range(m): x,y,c = map(int,input().split()) if x-1 != a_idx or y-1 != b_idx: ans ...
#!/usr/bin/env python3 a,b,m = map(int,input().split()) a = list(map(int,input().split())) b = list(map(int,input().split())) a_idx = a.index(min(a)) b_idx = b.index(min(b)) #print(a_idx,b_idx) ans = min(a)+min(b) for i in range(m): x,y,c = map(int,input().split()) if x-1 != a_idx or y-1 != b_idx: ans ...
[["-", 0, 657, 31, 657, 12, 206, 206, 657, 31, 22], ["+", 0, 657, 31, 657, 12, 206, 206, 657, 31, 22]]
5
187
A, B, M = [int(i) for i in input().split()] a = [int(i) for i in input().split()] b = [int(i) for i in input().split()] mina, minb = min(a), min(b) minv = mina+minb for _ in range(M): x, y, c = [int(i) for i in input().split()] x -= 1 y -= 1 minv = min(minv, a[x]+a[y]-c) print(minv)
A, B, M = [int(i) for i in input().split()] a = [int(i) for i in input().split()] b = [int(i) for i in input().split()] mina, minb = min(a), min(b) minv = mina+minb for _ in range(M): x, y, c = [int(i) for i in input().split()] x -= 1 y -= 1 minv = min(minv, a[x]+b[y]-c) print(minv)
[["-", 3, 4, 0, 657, 31, 657, 12, 206, 51, 22], ["+", 3, 4, 0, 657, 31, 657, 12, 206, 51, 22]]
5
134
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 7; typedef long long ll; int n, m, k; int a[maxn], b[maxn]; int main() { scanf("%d%d%d", &n, &m, &k); int mx_a = 1e9 + 1, mx_b = 1e9 + 1, ans = 1e9 + 1; for (int i = 0; i < n; i++) { scanf("%d", a + i); mx_a = min(mx_a, a[i]); } for...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 7; typedef long long ll; int n, m, k; int a[maxn], b[maxn]; int main() { scanf("%d%d%d", &n, &m, &k); int mx_a = 1e9 + 1, mx_b = 1e9 + 1, ans = 1e9 + 1; for (int i = 0; i < n; i++) { scanf("%d", a + i); mx_a = min(mx_a, a[i]); } for...
[["-", 0, 7, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 31, 22], ["-", 0, 1, 0, 11, 12, 2, 3, 4, 0, 22], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 22]]
1
237
A,B,M=map(int,input().split()) a=list(map(int,input().split())) b=list(map(int,input().split())) xyc=[list(map(int,input().split())) for i in range(M)] noti=min(a)+min(b) ans=0 c=0 for i in range(M): c=a[xyc[i][0]-1] + b[xyc[i][1]-1] -xyc[i][2] ans=min(noti,c) print(ans)
A,B,M=map(int,input().split()) a=list(map(int,input().split())) b=list(map(int,input().split())) xyc=[list(map(int,input().split())) for i in range(M)] noti=min(a)+min(b) ans=noti c=0 for i in range(M): c=a[xyc[i][0]-1] + b[xyc[i][1]-1] -xyc[i][2] ans=min(ans,c) print(ans)
[["-", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 12, 22], ["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22]]
5
150
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <cstring> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <string> #include <tuple> #include <vector> using namespace std; typedef long long int LL; typedef pair<int, int> P; typedef pair...
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <cstring> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <string> #include <tuple> #include <vector> using namespace std; typedef long long int LL; typedef pair<int, int> P; typedef pair...
[["-", 0, 11, 12, 16, 31, 16, 12, 69, 28, 22], ["+", 0, 11, 12, 16, 31, 16, 12, 69, 28, 22]]
1
555
#include <bits/stdc++.h> #define INF 1000000000 #define LINF 1000000000000000000 #define MOD 1000000007 #define mod 1000007 #define INF63 1061109567 #define INF127 9187201950435737471 #define UINF 18446744073709551615 #define F first #define S second #define ll long long #define N 100010 using namespace std; ll a, b, m...
#include <bits/stdc++.h> #define INF 1000000000 #define LINF 1000000000000000000 #define MOD 1000000007 #define mod 1000007 #define INF63 1061109567 #define INF127 9187201950435737471 #define UINF 18446744073709551615 #define F first #define S second #define ll long long #define N 100010 using namespace std; ll a, b, m...
[["-", 3, 4, 0, 16, 31, 16, 31, 69, 28, 22], ["+", 3, 4, 0, 16, 31, 16, 31, 69, 28, 22], ["-", 3, 4, 0, 16, 31, 16, 12, 69, 28, 22], ["+", 3, 4, 0, 16, 31, 16, 12, 69, 28, 22]]
1
252
A, B, M = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) xyc = [list(map(int, input().split())) for _ in range(M)] ans = min(a) + min(b) for i, (xi, yi, ci) in enumerate(xyc): ans = min(ans, a[xi - 1] + a[yi - 1] - ci) print(ans)
A, B, M = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) xyc = [list(map(int, input().split())) for _ in range(M)] ans = min(a) + min(b) for i, (xi, yi, ci) in enumerate(xyc): ans = min(ans, max(0, a[xi - 1] + b[yi - 1] - ci)) print(ans)
[["+", 0, 662, 12, 652, 3, 4, 0, 652, 63, 22], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 612], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 21], ["-", 3, 4, 0, 657, 31, 657, 12, 206, 51, 22], ["+", 3, 4, 0, 657, 31, 657, 12, 206, 51, 22], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
131
#include <algorithm> #include <iostream> #include <map> #include <vector> using namespace std; typedef long long int lli; typedef pair<lli, lli> pll; const lli mod = 998244353; const lli inf = 1e18; int main() { int a, b, m; cin >> a >> b >> m; vector<int> aa(m), bb(m); for (int i = 0; i < a; i++) { cin >>...
#include <algorithm> #include <iostream> #include <map> #include <vector> using namespace std; typedef long long int lli; typedef pair<lli, lli> pll; const lli mod = 998244353; const lli inf = 1e18; int main() { int a, b, m; cin >> a >> b >> m; vector<int> aa(a), bb(b); for (int i = 0; i < a; i++) { cin >>...
[["-", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78]]
1
220
#define _USE_MATH_DEFINES #include <bits/stdc++.h> //#define int ll #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(a) (a).begin(), (a).end() #define ln(a) cout << (a) << endl #define debug(a, n) ...
#define _USE_MATH_DEFINES #include <bits/stdc++.h> //#define int ll #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(a) (a).begin(), (a).end() #define ln(a) cout << (a) << endl #define debug(a, n) ...
[["-", 31, 16, 12, 69, 341, 342, 0, 16, 31, 22], ["+", 31, 16, 12, 69, 341, 342, 0, 16, 31, 22]]
1
2,095
#include <algorithm> #include <climits> #include <cmath> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <stack> #include <unordered_map> #include <vector> int main() { int a, b, m; std::cin >> a >> b >> m; std::vector<int>...
#include <algorithm> #include <climits> #include <cmath> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <stack> #include <unordered_map> #include <vector> int main() { int a, b, m; std::cin >> a >> b >> m; std::vector<int>...
[["-", 3, 4, 0, 16, 31, 16, 12, 69, 28, 22], ["+", 3, 4, 0, 16, 31, 16, 12, 69, 28, 22]]
1
202
a,b,m=map(int,input().split()) A=list(map(int,input().split())) B=list(map(int,input().split())) ans=min(A)+min(B) for i in range(m): x,y,c=map(int,input().split()) tmp=A[x-1]+B[y-1]+c ans=min(ans,tmp) print(ans)
a,b,m=map(int,input().split()) A=list(map(int,input().split())) B=list(map(int,input().split())) ans=min(A)+min(B) for i in range(m): x,y,c=map(int,input().split()) tmp=A[x-1]+B[y-1]-c ans=min(ans,tmp) print(ans)
[["-", 8, 196, 0, 1, 0, 662, 12, 657, 17, 72], ["+", 8, 196, 0, 1, 0, 662, 12, 657, 17, 33]]
5
118
#include <bits/stdc++.h> using namespace std; #define endl "\n" #define INF (int)9e18 #define HELL (int)(1e9 + 7) #define int long long #define double long double #define uint unsigned long long #define deb(x) cerr << #x << " => " << x << "\n" #define deba(x) ...
#include <bits/stdc++.h> using namespace std; #define endl "\n" #define INF (int)9e18 #define HELL (int)(1e9 + 7) #define int long long #define double long double #define uint unsigned long long #define deb(x) cerr << #x << " => " << x << "\n" #define deba(x) ...
[["-", 3, 4, 0, 83, 0, 16, 31, 16, 31, 22], ["-", 3, 4, 0, 83, 0, 16, 31, 16, 17, 72], ["-", 12, 2, 3, 4, 0, 83, 0, 16, 17, 33], ["-", 12, 2, 3, 4, 0, 83, 0, 16, 12, 22], ["-", 0, 11, 12, 2, 3, 4, 0, 83, 0, 21]]
1
388
#include <iostream> #include <vector> using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int A, B, M; cin >> A >> B >> M; vector<int> a(A), b(B); int mina = 1 << 30, minb = 1 << 30; for (int i = 0; i < A; i++) { cin >> a[i]; mina = min(mina, a[i]); } for (int j = 0; j...
#include <iostream> #include <vector> using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int A, B, M; cin >> A >> B >> M; vector<int> a(A), b(B); int mina = 1 << 30, minb = 1 << 30; for (int i = 0; i < A; i++) { cin >> a[i]; mina = min(mina, a[i]); } for (int j = 0; j...
[["-", 31, 16, 12, 69, 341, 342, 0, 16, 31, 22], ["+", 31, 16, 12, 69, 341, 342, 0, 16, 31, 22]]
1
209
A, B, M = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) amin = min(a) bmin = min(b) ans = amin + bmin for i in range(M): x, y, c = map(int, input().split()) ans = min( ans , a[x-1] + b[x-1] - c ) print(ans)
A, B, M = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) amin = min(a) bmin = min(b) ans = amin + bmin for i in range(M): x, y, c = map(int, input().split()) ans = min( ans , a[x-1] + b[y-1] - c ) print(ans)
[["-", 0, 657, 31, 657, 12, 206, 206, 657, 31, 22], ["+", 0, 657, 31, 657, 12, 206, 206, 657, 31, 22]]
5
121
#include "bits/stdc++.h" using namespace std; #define fst first #define scd second int main() { int a, b, m, mi = 100000000, ami = 100000000, bmi = 100000000, ai[100001], bi[100000]; scanf("%d%d%d", &a, &b, &m); for (int i = 0; i < a; ++i) { scanf("%d", &ai[i]); ami = min(ami, ai[i]); } ...
#include "bits/stdc++.h" using namespace std; #define fst first #define scd second int main() { int a, b, m, mi = 100000000, ami = 100000000, bmi = 100000000, ai[100001], bi[100000]; scanf("%d%d%d", &a, &b, &m); for (int i = 0; i < a; ++i) { scanf("%d", &ai[i]); ami = min(ami, ai[i]); } ...
[["-", 31, 16, 12, 69, 341, 342, 0, 16, 31, 22], ["+", 31, 16, 12, 69, 341, 342, 0, 16, 31, 22]]
1
229
#include <bits/stdc++.h> #define F first #define S second #define MP make_pair #define pb push_back #define all(a) a.begin(), a.end() #define lcm(a, b) (a) / __gcd((a), (b)) * (b) #define endl '\n' using namespace std; typedef long long LL; typedef pair<int, int> P; typedef pair<LL, LL> LP; static const int INF = I...
#include <bits/stdc++.h> #define F first #define S second #define MP make_pair #define pb push_back #define all(a) a.begin(), a.end() #define lcm(a, b) (a) / __gcd((a), (b)) * (b) #define endl '\n' using namespace std; typedef long long LL; typedef pair<int, int> P; typedef pair<LL, LL> LP; static const int INF = I...
[["-", 3, 4, 0, 16, 31, 16, 12, 69, 28, 22], ["+", 3, 4, 0, 16, 31, 16, 12, 69, 28, 22]]
1
424
#include <bits/stdc++.h> using namespace std; long long a, b, c, d, e, m, f[100009], g[100009], ff[100009], gg[100009], pas, i, j, zx, xc; int main() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); cin >> a >> b >> m; for (i = 1; i <= a; i++) { cin >> f[i]; ff[i] = f[i]; } sort(ff + 1...
#include <bits/stdc++.h> using namespace std; long long a, b, c, d, e, m, f[100009], g[100009], ff[100009], gg[100009], pas, i, j, zx, xc; int main() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); cin >> a >> b >> m; for (i = 1; i <= a; i++) { cin >> f[i]; ff[i] = f[i]; } sort(ff + 1...
[["-", 0, 11, 12, 16, 31, 16, 12, 69, 28, 22], ["+", 0, 11, 12, 16, 31, 16, 12, 69, 28, 22]]
1
241
#include <bits/stdc++.h> #define LL long long #define LD long double #define pb push_back #define mp make_pair #define ss(x) (int)x.size() #define fi first #define se second #define cat(x) cerr << #x << " = " << x << endl #define rep2(i, j, n) for (LL i = j; i <= n; ++i) #define rep(i, j, n) for (int i = j; i <= n; ++i...
#include <bits/stdc++.h> #define LL long long #define LD long double #define pb push_back #define mp make_pair #define ss(x) (int)x.size() #define fi first #define se second #define cat(x) cerr << #x << " = " << x << endl #define rep2(i, j, n) for (LL i = j; i <= n; ++i) #define rep(i, j, n) for (int i = j; i <= n; ++i...
[["-", 3, 4, 0, 16, 31, 16, 31, 69, 28, 22], ["+", 3, 4, 0, 16, 31, 16, 31, 69, 28, 22]]
1
280
// author:luckYrat(twitter:@luckYrat_) //#include <tourist> //#include <bits/stdc++.h> // def #include <iostream> #include <algorithm> #include <cmath> #include <iomanip> // array #include <climits> #include <map> #include <queue> #include <set> #include <stack> #include <utility> #include <vector> using namespace...
// author:luckYrat(twitter:@luckYrat_) //#include <tourist> //#include <bits/stdc++.h> // def #include <iostream> #include <algorithm> #include <cmath> #include <iomanip> // array #include <climits> #include <map> #include <queue> #include <set> #include <stack> #include <utility> #include <vector> using namespace...
[["-", 3, 4, 0, 16, 31, 16, 12, 69, 28, 22], ["+", 3, 4, 0, 16, 31, 16, 12, 69, 28, 22]]
1
432
#include <bits/stdc++.h> using namespace std; #define REP(i, s) for (int i = 0; i < s; ++i) #define ALL(v) (v).begin(), (v).end() #define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl #define EACH(i, s) \ for (__typeof__((s).begin()...
#include <bits/stdc++.h> using namespace std; #define REP(i, s) for (int i = 0; i < s; ++i) #define ALL(v) (v).begin(), (v).end() #define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl #define EACH(i, s) \ for (__typeof__((s).begin()...
[["-", 3, 4, 0, 16, 31, 16, 12, 69, 28, 22], ["+", 3, 4, 0, 16, 31, 16, 12, 69, 28, 22]]
1
622
def main(): a_n, b_n, m = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) ans = 10**8 for _ in range(m): x, y, c = map(int, input().split()) x -= 1 y -= 1 buf = a[x] + b[x] - c if buf < ans: ans = b...
def main(): a_n, b_n, m = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) ans = 10**8 for _ in range(m): x, y, c = map(int, input().split()) x -= 1 y -= 1 buf = a[x] + b[y] - c if buf < ans: ans = b...
[["-", 0, 662, 12, 657, 31, 657, 12, 206, 206, 22], ["+", 0, 662, 12, 657, 31, 657, 12, 206, 206, 22]]
5
163
#include <algorithm> #include <array> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <deque> #include <fstream> #include <functional> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <st...
#include <algorithm> #include <array> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <deque> #include <fstream> #include <functional> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <st...
[["-", 0, 16, 31, 16, 12, 69, 341, 342, 0, 22], ["+", 0, 16, 31, 16, 12, 69, 341, 342, 0, 22]]
1
234
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <cstdlib> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; using llong = long long; llong A, B, M; llong a[100005]; llong...
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <cstdlib> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; using llong = long long; llong A, B, M; llong a[100005]; llong...
[["-", 3, 4, 0, 16, 31, 16, 12, 69, 28, 22], ["+", 3, 4, 0, 16, 31, 16, 12, 69, 28, 22]]
1
226
a,b,m = map(int,input().split()) ref = list(map(int,input().split())) mic = list(map(int,input().split())) ans = min(ref)+min(mic) for i in range(m): x,y,c = map(int,input().split()) x-=1 y-=1 if ref[x]+ref[y]-c < ans: ans = ref[x]+ref[y]-c print(ans)
a,b,m = map(int,input().split()) ref = list(map(int,input().split())) mic = list(map(int,input().split())) ans = min(ref)+min(mic) for i in range(m): x,y,c = map(int,input().split()) x-=1 y-=1 if ref[x]+mic[y]-c < ans: ans = ref[x]+mic[y]-c print(ans)
[["-", 15, 666, 0, 657, 31, 657, 12, 206, 51, 22], ["+", 15, 666, 0, 657, 31, 657, 12, 206, 51, 22], ["-", 0, 662, 12, 657, 31, 657, 12, 206, 51, 22], ["+", 0, 662, 12, 657, 31, 657, 12, 206, 51, 22]]
5
127
A, B, M = map(int, input().split()) a = [int(x) for x in input().split()] b = [int(x) for x in input().split()] ans = min(a)+min(b) for i in range(M): x,y,c = map(int, input().split()) ans = min(ans,a[x-1]+b[x-1]-c) print(ans)
A, B, M = map(int, input().split()) a = [int(x) for x in input().split()] b = [int(x) for x in input().split()] ans = min(a)+min(b) for i in range(M): x, y, c = map(int, input().split()) ans = min(ans, a[x-1]+b[y-1]-c) print(ans)
[["-", 0, 657, 31, 657, 12, 206, 206, 657, 31, 22], ["+", 0, 657, 31, 657, 12, 206, 206, 657, 31, 22]]
5
117
#!/usr/bin/env python3 import sys, math, itertools, collections, bisect input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') inf = float('inf') ;mod = 10**9+7 mans = inf ;ans = 0 ;count = 0 ;pro = 1 a,b,m = map(int,input().split()) A = list(map(int,input().split())) B = list(map(int,input().split())) a...
#!/usr/bin/env python3 import sys, math, itertools, collections, bisect input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') inf = float('inf') ;mod = 10**9+7 mans = inf ;ans = 0 ;count = 0 ;pro = 1 a,b,m = map(int,input().split()) A = list(map(int,input().split())) B = list(map(int,input().split())) a...
[["-", 0, 7, 8, 196, 0, 1, 0, 677, 31, 22], ["+", 0, 7, 8, 196, 0, 1, 0, 677, 31, 22], ["-", 0, 662, 12, 657, 31, 657, 12, 206, 206, 22], ["+", 0, 662, 12, 657, 31, 657, 12, 206, 206, 22]]
5
194
#include <bits/stdc++.h> #define eb emplace_back #define all(v) v.begin(), v.end() using namespace std; using ll = long long; using P = pair<ll, ll>; const ll INF = 1LL << 60; const ll MOD = 998244353LL; template <class T> void chmin(T &a, T b) { a = min(a, b); } template <class T> void chmax(T &a, T b) { a = max(a, b)...
#include <bits/stdc++.h> #define eb emplace_back #define all(v) v.begin(), v.end() using namespace std; using ll = long long; using P = pair<ll, ll>; const ll INF = 1LL << 60; const ll MOD = 998244353LL; template <class T> void chmin(T &a, T b) { a = min(a, b); } template <class T> void chmax(T &a, T b) { a = max(a, b)...
[["-", 3, 4, 0, 16, 31, 16, 12, 69, 28, 22], ["+", 3, 4, 0, 16, 31, 16, 12, 69, 28, 22]]
1
288
#include <bits/stdc++.h> //#define ll long long int32_t //#define int long long int #define getFaster \ ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL) #define rep(i, init, n) for (int i = init; i < n; i++) #define rev(i, n, init) for (int i...
#include <bits/stdc++.h> //#define ll long long int32_t //#define int long long int #define getFaster \ ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL) #define rep(i, init, n) for (int i = init; i < n; i++) #define rev(i, n, init) for (int i...
[["-", 31, 16, 12, 69, 341, 342, 0, 16, 31, 22], ["+", 31, 16, 12, 69, 341, 342, 0, 16, 31, 22]]
1
272
#include <bits/stdc++.h> using namespace std; const int N = 1e5; int a, b, m; int li[N + 5], li2[N + 5]; int main() { cin >> a >> b >> m; int mini = 1e9; int ans = 0; for (int i = 1; i <= a; i++) cin >> li[i], mini = min(mini, li[i]); ans = mini; mini = 1e9; for (int i = 1; i <= b; i++) cin >> ...
#include <bits/stdc++.h> using namespace std; const int N = 1e5; int a, b, m; int li[N + 5], li2[N + 5]; int main() { cin >> a >> b >> m; int mini = 1e9; int ans = 0; for (int i = 1; i <= a; i++) cin >> li[i], mini = min(mini, li[i]); ans = mini; mini = 1e9; for (int i = 1; i <= b; i++) cin >> ...
[["+", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 17, 107], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["-", 49, 50, 51, 16, 31, 16, 12, 69, 28, 22], ["+", 49, 50, 51, 16, 31, 16, 12, 69, 28, 22]]
1
196
#include <algorithm> #include <iostream> #include <stdio.h> #include <string> #include <vector> using namespace std; int main() { vector<int> va; vector<int> vb; int a, b, m; cin >> a >> b >> m; int aa, bb; for (int i = 0; i < a; i++) { cin >> aa; va.push_back(aa); } for (int i = 0; i < a; i+...
#include <algorithm> #include <iostream> #include <stdio.h> #include <string> #include <vector> using namespace std; int main() { vector<int> va; vector<int> vb; int a, b, m; cin >> a >> b >> m; int aa, bb; for (int i = 0; i < a; i++) { cin >> aa; va.push_back(aa); } for (int i = 0; i < b; i+...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]]
1
214
#include <bits/stdc++.h> using namespace std; int a[100005], b[100005], c[100005], d[100005]; int main() { ios::sync_with_stdio(false); int A, B, M, x, y, n; cin >> A >> B >> M; for (int i = 1; i <= A; i++) cin >> a[i], c[i] = a[i]; for (int i = 1; i <= B; i++) cin >> b[i], d[i] = b[i]; sort(c + 1, ...
#include <bits/stdc++.h> using namespace std; int a[100005], b[100005], c[100005], d[100005]; int main() { ios::sync_with_stdio(false); int A, B, M, x, y, n; cin >> A >> B >> M; for (int i = 1; i <= A; i++) cin >> a[i], c[i] = a[i]; for (int i = 1; i <= B; i++) cin >> b[i], d[i] = b[i]; sort(c + 1, ...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 0, 21], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 49, 22], ["-", 0, 7, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 31, 22], ["-", 3, 4, 0, 16, 31, 16, 12, 69, 28, 22], ["+", 3, 4, 0, 16, 31, 16, 12, 69, 28, 22], ["-", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["+", 8, 9, 0, 1, 0, 16, 3...
1
216
a,b,m=map(int,input().split()) ai=list(map(int, input().split())) bi=list(map(int, input().split())) sm=[list(map(int, input().split())) for _ in range(m)] k=min(ai)+min(bi) for x in range(m): l=ai[sm[x][0]-1]+bi[sm[x][1]-1]-sm[x][2] ans=min(k,l) print(ans)
a,b,m=map(int,input().split()) ai=list(map(int, input().split())) bi=list(map(int, input().split())) sm=[list(map(int, input().split())) for _ in range(m)] k=min(ai)+min(bi) for x in range(m): l=ai[sm[x][0]-1]+bi[sm[x][1]-1]-sm[x][2] k=min(k,l) print(k)
[["-", 0, 7, 8, 196, 0, 1, 0, 662, 31, 22], ["+", 0, 7, 8, 196, 0, 1, 0, 662, 31, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22]]
5
144
a,b,m = map(int,input().split()) ref = list(map(int,input().split())) ran = list(map(int,input().split())) ans = min(ref) + min(ran) for i in range(m): t = list(map(int,input().split())) p = t[0] q = t[1] c = t[2] if (len(ref) <= p and len(ran) <= q): if ref[p - 1] + ran[q - 1] - c < ans: ans = r...
a,b,m = map(int,input().split()) ref = list(map(int,input().split())) ran = list(map(int,input().split())) ans = min(ref) + min(ran) for i in range(m): t = list(map(int,input().split())) p = t[0] q = t[1] c = t[2] if (len(ref) >= p and len(ran) >= q): if ref[p - 1] + ran[q - 1] - c < ans: ans = r...
[["-", 0, 57, 15, 23, 0, 679, 31, 666, 667, 19], ["+", 0, 57, 15, 23, 0, 679, 31, 666, 667, 20], ["-", 0, 57, 15, 23, 0, 679, 12, 666, 667, 19], ["+", 0, 57, 15, 23, 0, 679, 12, 666, 667, 20]]
5
163
#include <bits/stdc++.h> using namespace std; #define rep(i, N) for (int i = 0, i##_max = (N); i < i##_max; ++i) #define repp(i, l, r) for (int i = (l), i##_max = (r); i < i##_max; ++i) #define per(i, N) for (int i = (N)-1; i >= 0; --i) #define perr(i, l, r) for (int i = r - 1, i##_min(l); i >= i##_min; --i) #define al...
#include <bits/stdc++.h> using namespace std; #define rep(i, N) for (int i = 0, i##_max = (N); i < i##_max; ++i) #define repp(i, l, r) for (int i = (l), i##_max = (r); i < i##_max; ++i) #define per(i, N) for (int i = (N)-1; i >= 0; --i) #define perr(i, l, r) for (int i = r - 1, i##_min(l); i >= i##_min; --i) #define al...
[["-", 0, 16, 31, 16, 12, 69, 341, 342, 0, 22], ["+", 0, 16, 31, 16, 12, 69, 341, 342, 0, 22]]
1
409
A,B,M = map(int,input().split(" ")) a = list(map(int,input().split(" "))) b = list(map(int,input().split(" "))) tmp = min(a) + min(b) for i in range(M): x,y,c = map(int,input().split(" ")) sum1 = a[x-1]+b[y-1]-c ans = min(tmp,sum1) print(ans)
A,B,M = map(int,input().split(" ")) a = list(map(int,input().split(" "))) b = list(map(int,input().split(" "))) ans = min(a) + min(b) for i in range(M): x,y,c = map(int,input().split(" ")) tmp = a[x-1]+b[y-1]-c ans = min(tmp,ans) print(ans)
[["-", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["-", 0, 7, 8, 196, 0, 1, 0, 662, 31, 22], ["+", 0, 7, 8, 196, 0, 1, 0, 662, 31, 22], ["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22]]
5
130
//{{{ #include <bits/stdc++.h> using namespace std; const string truename = "Yes"; const string falsename = "No"; struct IoSetup { IoSetup() { cin.tie(nullptr); // ios::sync_with_stdio(false); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); }; } ioSetup; //{{{ rep rrep loop ...
//{{{ #include <bits/stdc++.h> using namespace std; const string truename = "Yes"; const string falsename = "No"; struct IoSetup { IoSetup() { cin.tie(nullptr); // ios::sync_with_stdio(false); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); }; } ioSetup; //{{{ rep rrep loop ...
[["-", 3, 4, 0, 16, 31, 16, 12, 69, 28, 22], ["+", 3, 4, 0, 16, 31, 16, 12, 69, 28, 22]]
1
2,580
def main(): A,B,M = map(int,input().split()) val_a = [int(i) for i in input().split()] val_b = [int(j) for j in input().split()] lucky = [map(int,input().split()) for _ in range(M)] min_a = min(val_a) min_b = min(val_b) ans = min_a + min_b for i in range(M): a,b,c = lucky[i] ...
def main(): A,B,M = map(int,input().split()) val_a = [int(i) for i in input().split()] val_b = [int(j) for j in input().split()] lucky = [map(int,input().split()) for _ in range(M)] min_a = min(val_a) min_b = min(val_b) ans = min_a + min_b for i in range(M): a,b,c = lucky[i] ...
[["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22]]
5
156
A, B, M = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) min = min(a) + min(b) for i in range(M): x, y, c = list(map(int, input().split())) tmp = a[x - 1] + b[y - 1] + c if min > tmp: min = tmp print(min)
A, B, M = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) min = min(a) + min(b) for i in range(M): x, y, c = list(map(int, input().split())) tmp = a[x - 1] + b[y - 1] - c if min > tmp: min = tmp print(min)
[["-", 8, 196, 0, 1, 0, 662, 12, 657, 17, 72], ["+", 8, 196, 0, 1, 0, 662, 12, 657, 17, 33]]
5
121
#pragma GCC optimize("O3") #include <bits/stdc++.h> #define ll long long #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> #define pq priority_queue #define pb push_back #de...
#pragma GCC optimize("O3") #include <bits/stdc++.h> #define ll long long #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> #define pq priority_queue #define pb push_back #de...
[["+", 31, 16, 31, 69, 341, 342, 0, 16, 17, 33], ["+", 31, 16, 31, 69, 341, 342, 0, 16, 12, 13], ["+", 31, 16, 12, 69, 341, 342, 0, 16, 17, 33], ["+", 31, 16, 12, 69, 341, 342, 0, 16, 12, 13]]
1
566
A, B, M = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) x = [0] * M y = [0] * M c = [0] * M for i in range(M): x[i], y[i], c[i] = map(int, input().split()) min_cost = min(a) + min(b) for i in range(M): min_cost = min(a[x[i]-1] + b[x[i]-1] - c[i], min_cost) ...
A, B, M = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) x = [0] * M y = [0] * M c = [0] * M for i in range(M): x[i], y[i], c[i] = map(int, input().split()) min_cost = min(a) + min(b) for i in range(M): min_cost = min(a[x[i]-1] + b[y[i]-1] - c[i], min_cost) prin...
[["-", 31, 657, 12, 206, 206, 657, 31, 206, 51, 22], ["+", 31, 657, 12, 206, 206, 657, 31, 206, 51, 22]]
5
162
A, B, M = [int(n) for n in input().split()] a = [int(n) for n in input().split()] b = [int(n) for n in input().split()] ma = sorted(a)[0] mb = sorted(b)[0] XY = {} ans = 10**5+1 for m in range(M): x, y, c = [int(n) for n in input().split()] dv = a[x-1] + b[y-1] - c mv = min((ma+mb), dv) if ans > mv: ...
A, B, M = [int(n) for n in input().split()] a = [int(n) for n in input().split()] b = [int(n) for n in input().split()] ma = sorted(a)[0] mb = sorted(b)[0] XY = {} ans = ma + mb for m in range(M): x, y, c = [int(n) for n in input().split()] dv = a[x-1] + b[y-1] - c mv = min((ma+mb), dv) if ans > mv: ...
[["-", 0, 1, 0, 662, 12, 657, 31, 657, 31, 612], ["-", 0, 1, 0, 662, 12, 657, 31, 657, 17, 578], ["-", 0, 1, 0, 662, 12, 657, 31, 657, 12, 612], ["+", 0, 656, 0, 1, 0, 662, 12, 657, 31, 22], ["-", 0, 656, 0, 1, 0, 662, 12, 657, 12, 612], ["+", 0, 656, 0, 1, 0, 662, 12, 657, 12, 22]]
5
158
def resolve(): input = sys.stdin.readline A, B, M = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) grid=[list(map(int,input().split())) for i in range(M)] res = min(a) + min(b) for x, y, c in grid: res = min(res, a[x-1]+b[y-1]-c) ...
import sys def resolve(): input = sys.stdin.readline A, B, M = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) grid=[list(map(int,input().split())) for i in range(M)] res = min(a) + min(b) for x, y, c in grid: res = min(res, a[x-1]...
[["+", 36, 36, 36, 36, 0, 656, 0, 596, 0, 487], ["+", 36, 36, 0, 656, 0, 596, 141, 673, 0, 22]]
5
139
#include "bits/stdc++.h" using namespace std; typedef long long int ll; typedef pair<ll, ll> pi; typedef pair<pair<ll, ll>, ll> pii; vector<ll> vec; vector<vector<ll>> vec2; ll MOD = 1000000007; ll INF = 1145141919454519; int main() { ll A, B, M; cin >> A >> B >> M; vector<ll> a(A, 0); vector<ll> b(B, 0); ...
#include "bits/stdc++.h" using namespace std; typedef long long int ll; typedef pair<ll, ll> pi; typedef pair<pair<ll, ll>, ll> pii; vector<ll> vec; vector<vector<ll>> vec2; ll MOD = 1000000007; ll INF = 1145141919454519; int main() { ll A, B, M; cin >> A >> B >> M; vector<ll> a(A, 0); vector<ll> b(B, 0); ...
[["-", 0, 11, 12, 2, 3, 4, 0, 69, 28, 22], ["+", 0, 11, 12, 2, 3, 4, 0, 69, 28, 22]]
1
256
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, a, b) for (ll i = a; i <= b; i++) #define repr(i, a, b) for (ll i = a; i >= b; i--) int main() { // your code goes here ll a, b, m, s[100005], t[100005], ans; ll e = 10000000000, f = 10000000000; cin >> a >> b >> m; rep(i, 1, ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, a, b) for (ll i = a; i <= b; i++) #define repr(i, a, b) for (ll i = a; i >= b; i--) int main() { // your code goes here ll a, b, m, s[100005], t[100005], ans; ll e = 10000000000, f = 10000000000; cin >> a >> b >> m; rep(i, 1, ...
[["-", 3, 4, 0, 16, 31, 16, 12, 69, 28, 22], ["+", 3, 4, 0, 16, 31, 16, 12, 69, 28, 22]]
1
194
import sys input = sys.stdin.readline A,B,m = map(int,input().split()) a = list(map(int,input().split())) b = list(map(int,input().split())) ans = min(a) + min(b) for i in range(m): sum = 0 x,y,c = map(int,input().split()) sum = a[x] + b[y] - c ans = min(ans,sum) print(ans)
import sys input = sys.stdin.readline A,B,m = map(int,input().split()) a = list(map(int,input().split())) b = list(map(int,input().split())) ans = min(a) + min(b) for i in range(m): sum = 0 x,y,c = map(int,input().split()) sum = a[x-1] + b[y-1] - c ans = min(ans,sum) print(ans)
[["+", 12, 657, 31, 657, 31, 206, 206, 657, 17, 33], ["+", 12, 657, 31, 657, 31, 206, 206, 657, 12, 612], ["+", 12, 657, 31, 657, 12, 206, 206, 657, 17, 33], ["+", 12, 657, 31, 657, 12, 206, 206, 657, 12, 612]]
5
126
# coding: utf-8 # Your code here! x, y, m = [int(i) for i in input().split()] a = [int(i) for i in input().split()] b = [int(i) for i in input().split()] num = [min(a)+min(b)] for _ in range(m): tmp = [int(i) for i in input().split()] num.append(a[tmp[0]]-1+b[tmp[1]]-1-tmp[2]) print(min(num))
# coding: utf-8 # Your code here! x, y, m = [int(i) for i in input().split()] a = [int(i) for i in input().split()] b = [int(i) for i in input().split()] num = [min(a)+min(b)] for _ in range(m): tmp = [int(i) for i in input().split()] num.append(a[tmp[0]-1]+b[tmp[1]-1]-tmp[2]) print(min(num))
[["-", 31, 657, 31, 657, 31, 657, 31, 206, 0, 73], ["+", 3, 4, 0, 657, 31, 657, 31, 206, 0, 73], ["-", 31, 657, 31, 657, 12, 206, 206, 206, 0, 73], ["+", 3, 4, 0, 657, 31, 657, 12, 206, 0, 73]]
5
135
#pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<ll, ll>; template <class T> using V = vector<T>; #define fi first #define se second #define all(v) (v).begin(), (v).end() const ll inf = (1e18); const ll mod = 1000000007; ll gcd(ll a, ll b) { return b ? gcd(b,...
#pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<ll, ll>; template <class T> using V = vector<T>; #define fi first #define se second #define all(v) (v).begin(), (v).end() const ll inf = (1e18); const ll mod = 1000000007; ll gcd(ll a, ll b) { return b ? gcd(b,...
[["-", 3, 4, 0, 16, 31, 16, 31, 69, 28, 22], ["+", 3, 4, 0, 16, 31, 16, 31, 69, 28, 22], ["-", 3, 4, 0, 16, 31, 16, 12, 69, 28, 22], ["+", 3, 4, 0, 16, 31, 16, 12, 69, 28, 22]]
1
417
A, B, M = map(int, input().split()) a = [int(x) for x in input().split()] b = [int(x) for x in input().split()] result = min(a) + min(b) for i in range(M): x, y, c = map(int, input().split()) sum = a[x] + b[y] - c if sum < result: result = sum print(result)
A, B, M = map(int, input().split()) a = [int(x) for x in input().split()] b = [int(x) for x in input().split()] result = min(a) + min(b) for i in range(M): x, y, c = map(int, input().split()) sum = a[x-1] + b[y-1] - c if sum < result: result = sum print(result)
[["+", 12, 657, 31, 657, 31, 206, 206, 657, 17, 33], ["+", 12, 657, 31, 657, 31, 206, 206, 657, 12, 612], ["+", 12, 657, 31, 657, 12, 206, 206, 657, 17, 33], ["+", 12, 657, 31, 657, 12, 206, 206, 657, 12, 612]]
5
116
data = input().split(" ") A = input().split(" ") B = input().split(" ") total = 100000 a = 100000 b = 100000 j = 0 for i in data: data[j] = int(i) j += 1 j = 0 for i in A: A[j] = int(i) j += 1 j = 0 for i in B: B[j] = int(i) j += 1 for i in range(data[2]): data1 = input().split() j = 0...
data = input().split(" ") A = input().split(" ") B = input().split(" ") total = 1000000 a = 1000000 b = 1000000 j = 0 for i in data: data[j] = int(i) j += 1 j = 0 for i in A: A[j] = int(i) j += 1 j = 0 for i in B: B[j] = int(i) j += 1 for i in range(data[2]): data1 = input().split() j ...
[["-", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612], ["-", 31, 657, 12, 206, 206, 657, 31, 206, 51, 22], ["+", 31, 657, 12, 206, 206, 657, 31, 206, 51, 22]]
5
221
a,b,m = input().split() a = int(a) b = int(b) m = int(m) al = input().split() bl = input().split() ml = [list(map(int, input().split())) for i in range(m)] al = list(map(int, al)) bl = list(map(int, bl)) al = sorted(al) bl = sorted(bl) tmp = al[0] + bl[0] comp = 0 fp = tmp for i in ml: comp = al[i[0]-1] + bl[i[1...
a,b,m = input().split() a = int(a) b = int(b) m = int(m) al = input().split() bl = input().split() ml = [list(map(int, input().split())) for i in range(m)] al = list(map(int, al)) bl = list(map(int, bl)) als = sorted(al) bls = sorted(bl) tmp = als[0] + bls[0] comp = 0 fp = tmp for i in ml: comp = al[i[0]-1] + bl...
[["-", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["-", 0, 1, 0, 662, 12, 657, 31, 206, 51, 22], ["+", 0, 1, 0, 662, 12, 657, 31, 206, 51, 22], ["-", 0, 1, 0, 662, 12, 657, 12, 206, 51, 22], ["+", 0, 1, 0, 662, 12, 657, 12, 206, 51, 22]]
5
169
#include <bits/stdc++.h> #define pb push_back #define sc1(x) scanf("%lld", &x) #define sc2(x, y) scanf("%lld%lld", &x, &y) #define sc3(x, y, z) scanf("%lld%lld%lld", &x, &y, &z) using namespace std; typedef long long int ll; ll arr[100005], brr[100005]; int main() { ll a, b, M; sc3(a, b, M); ll ac = INT_MAX; ...
#include <bits/stdc++.h> #define pb push_back #define sc1(x) scanf("%lld", &x) #define sc2(x, y) scanf("%lld%lld", &x, &y) #define sc3(x, y, z) scanf("%lld%lld%lld", &x, &y, &z) using namespace std; typedef long long int ll; ll arr[100005], brr[100005]; int main() { ll a, b, M; sc3(a, b, M); ll ac = INT_MAX; ...
[["-", 3, 4, 0, 16, 31, 16, 12, 69, 28, 22], ["+", 3, 4, 0, 16, 31, 16, 12, 69, 28, 22]]
1
225
A, B, M = map(int,input().split()) a = list(map(int,input().split())) b = list(map(int,input().split())) price1 = min(a) + min(b) for _ in range(M): x, y, c = map(int,input().split()) price2 = a[x-1] + a[y-1] - c if price1 > price2: price1 = price2 print(price1)
A, B, M = map(int,input().split()) a = list(map(int,input().split())) b = list(map(int,input().split())) price1 = min(a) + min(b) for _ in range(M): x, y, c = map(int,input().split()) price2 = a[x-1] + b[y-1] - c if price1 > price2: price1 = price2 print(price1)
[["-", 0, 662, 12, 657, 31, 657, 12, 206, 51, 22], ["+", 0, 662, 12, 657, 31, 657, 12, 206, 51, 22]]
5
118
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll INF = 9223372036854775807; const ll half_inf = 0x3f3f3f3f; const ll inf = 0x7fffffff; const ll mod = 1e9 + 7; const ll maxn = 200005; const ll N = 500005; struct p { int v, num; } a[100005], b[100005]; bool cmp(struct p q, struct p w) { if...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll INF = 9223372036854775807; const ll half_inf = 0x3f3f3f3f; const ll inf = 0x7fffffff; const ll mod = 1e9 + 7; const ll maxn = 200005; const ll N = 500005; struct p { int v, num; } a[100005], b[100005]; bool cmp(struct p q, struct p w) { if...
[["-", 0, 14, 8, 9, 0, 7, 8, 9, 0, 45], ["-", 0, 14, 8, 9, 0, 7, 8, 9, 0, 46], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]]
1
565
# -*- coding: utf-8 -*- A,B,M = list(map(int,input().split())) a = list(map(int,input().split())) b = list(map(int,input().split())) mini = min(a)+ min(b) def check(Mlist, mini): if mini > a[Mlist[0]-1]+b[Mlist[1]-1]-Mlist[2]: return a[Mlist[0]-1]+b[Mlist[1]-1]-Mlist[2] for i in range(M): mini = chec...
# -*- coding: utf-8 -*- A,B,M = list(map(int,input().split())) a = list(map(int,input().split())) b = list(map(int,input().split())) mini = min(a)+ min(b) def check(Mlist, mini): #print(Mlist) if mini > a[Mlist[0]-1]+b[Mlist[1]-1]-Mlist[2]: return a[Mlist[0]-1]+b[Mlist[1]-1]-Mlist[2] return mini ...
[["+", 0, 656, 0, 14, 8, 196, 0, 37, 0, 38], ["+", 0, 656, 0, 14, 8, 196, 0, 37, 0, 22]]
5
162
A,B,M = map(int,input().split()) A_ = list(map(int,input().split())) B_ = list(map(int,input().split())) mini =min(A_) + min(B_) for i in range(M): array = list(map(int,input().split())) m = A_[array[0]-1] + B_[array[0]-1] -array[2] if(mini > m): mini = m print(mini)
A,B,M = map(int,input().split()) A_ = list(map(int,input().split())) B_ = list(map(int,input().split())) mini =min(A_) + min(B_) for i in range(M): array = list(map(int,input().split())) m = A_[array[0]-1] + B_[array[1]-1] -array[2] if(mini > m): mini = m print(mini)
[["-", 31, 657, 12, 206, 206, 657, 31, 206, 206, 612], ["+", 31, 657, 12, 206, 206, 657, 31, 206, 206, 612]]
5
128
aa, bb, m = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) couponMin = float("INF") for i in range(m): x, y, c = map(int, input().split()) cc = a[x - 1] + b[x - 1] - c couponMin = min(couponMin, cc) print(min(min(a) + min(b), couponMin))
aa, bb, m = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) couponMin = float("INF") for i in range(m): x, y, c = map(int, input().split()) cc = a[x - 1] + b[y - 1] - c couponMin = min(couponMin, cc) print(min(min(a) + min(b), couponMin))
[["-", 12, 657, 31, 657, 12, 206, 206, 657, 31, 22], ["+", 12, 657, 31, 657, 12, 206, 206, 657, 31, 22]]
5
128
A, B, M = input().split() A=int(A) B=int(B) M=int(M) a = list(map(int, input().split())) b = list(map(int, input().split())) x = [list(map(int, input().split())) for i in range(M)] dis = [] for i in range(M): m = x[i][0]-1 n = x[i][0]-1 dis.append(a[m] + b[n] - x[i][2]) a.sort() b.sort() dis.append...
A, B, M = input().split() A=int(A) B=int(B) M=int(M) a = list(map(int, input().split())) b = list(map(int, input().split())) x = [list(map(int, input().split())) for i in range(M)] dis = [] for i in range(M): m = x[i][0]-1 n = x[i][1]-1 dis.append(a[m] + b[n] - x[i][2]) a.sort() b.sort() dis.append...
[["-", 0, 1, 0, 662, 12, 657, 31, 206, 206, 612], ["+", 0, 1, 0, 662, 12, 657, 31, 206, 206, 612]]
5
178
R = lambda: tuple(map(int, input().split())) A, B, M = R() a, b = R(), R() d = (R() for _ in range(M)) print(min([min(a) + min(b)] + [a[x - 1] + b[x - 1] - c for x, y, c in d]))
R = lambda: tuple(map(int, input().split())) A, B, M = R() a, b = R(), R() d = (R() for _ in range(M)) print(min([min(a) + min(b)] + [a[x - 1] + b[y - 1] - c for x, y, c in d]))
[["-", 8, 657, 31, 657, 12, 206, 206, 657, 31, 22], ["+", 8, 657, 31, 657, 12, 206, 206, 657, 31, 22]]
5
96
a,b,m = map(int,input().split()) A = list(map(int,input().split())) B = list(map(int,input().split())) X = [] Y = [] C = [] total = 2*10**5 for i in range(m): x,y,c = map(int,input().split()) X.append(x) Y.append(y) C.append(c) for i in range(m): result = int(A[int(X[int(i)])-1])+int(B[int(Y[int(i)]...
a,b,m = map(int,input().split()) A = list(map(int,input().split())) B = list(map(int,input().split())) #print(A,B) X = [] Y = [] C = [] total = 2*10**5 for i in range(m): x,y,c = map(int,input().split()) X.append(x) Y.append(y) C.append(c) for i in range(m): result = int(A[int(X[int(i)])-1])+int(B[...
[["-", 0, 656, 0, 57, 15, 23, 0, 666, 0, 22], ["+", 0, 656, 0, 57, 15, 23, 0, 666, 0, 22], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 22]]
5
229
A, B, M = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) s = [] s.append(min(a) + min(b)) for i in range(M): x_i, y_i, c_i = map(int, input().split()) minus = a[x_i - 1] + a[y_i - 1] - c_i s.append(minus) print(min(s))
A, B, M = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) s = [] s.append(min(a) + min(b)) for i in range(M): x_i, y_i, c_i = map(int, input().split()) minus = a[x_i - 1] + b[y_i - 1] - c_i s.append(minus) print(min(s))
[["-", 0, 662, 12, 657, 31, 657, 12, 206, 51, 22], ["+", 0, 662, 12, 657, 31, 657, 12, 206, 51, 22]]
5
126
#include <stdio.h> #include <stdlib.h> int main() { int a, b, m, min = 10000000; int *an; int *bn; scanf("%d%d%d", &a, &b, &m); an = (int *)malloc(sizeof(int) * (a + 1)); bn = (int *)malloc(sizeof(int) * (b + 1)); for (int i = 1; i <= a; i++) { scanf("%d", &an[i]); } for (int i = 1; i <= b; i++) ...
#include <stdio.h> #include <stdlib.h> int main() { int a, b, m, min = 10000000; int *an; int *bn; scanf("%d%d%d", &a, &b, &m); an = (int *)malloc(sizeof(int) * (a + 1)); bn = (int *)malloc(sizeof(int) * (b + 1)); for (int i = 1; i <= a; i++) { scanf("%d", &an[i]); } for (int i = 1; i <= b; i++) ...
[["-", 8, 9, 0, 57, 15, 23, 0, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 17, 18]]
0
320
A,B,M=list(map(int, input().split())) a=list(map(int, input().split())) b=list(map(int, input().split())) mi=min(a)+min(b) for i in range(0,M): Data=list(map(int, input().split())) wari=a[Data[0]]+b[Data[1]]-Data[2] if(mi>wari): mi=wari print(mi)
A,B,M=list(map(int, input().split())) a=list(map(int, input().split())) b=list(map(int, input().split())) mi=min(a)+min(b) for i in range(0,M): Data=list(map(int, input().split())) wari=a[Data[0]-1]+b[Data[1]-1]-Data[2] if(mi>wari): mi=wari print(mi)
[["+", 12, 657, 31, 657, 31, 206, 206, 657, 17, 33], ["+", 12, 657, 31, 657, 31, 206, 206, 657, 12, 612], ["+", 12, 657, 31, 657, 12, 206, 206, 657, 17, 33], ["+", 12, 657, 31, 657, 12, 206, 206, 657, 12, 612]]
5
129