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 <algorithm> #include <cmath> #include <iostream> using namespace std; const int maxn = 2e3 + 10; typedef long long int ll; int dis[maxn]; void solved() { int n, x, y; cin >> n >> x >> y; for (int i = 1; i <= n; i++) { for (int j = i + 1; j <= n; j++) { int di = min(abs(i - j), abs(i - x) + 1 +...
#include <algorithm> #include <cmath> #include <iostream> using namespace std; const int maxn = 2e3 + 10; typedef long long int ll; int dis[maxn]; void solved() { int n, x, y; cin >> n >> x >> y; for (int i = 1; i <= n; i++) { for (int j = i + 1; j <= n; j++) { int di = min(abs(i - j), abs(i - x) + 1 +...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18]]
1
181
n,x,y = map(int, input().split()) t = [0 for i in range(n-1)] x = x-1 y = y-1 for i in range(0,n): for j in range(i,n): a = abs(i-x)+abs(j-y)+1 b = abs(i-j) if a < b: t[a-1] += 1 else: t[b-1] += 1 for k in range(0,n-1): print(int(t[k]))
n,x,y = map(int, input().split()) t = [0 for i in range(n)] x = x-1 y = y-1 for i in range(0,n): for j in range(i,n): a = abs(i-x)+abs(j-y)+1 b = abs(i-j) if a < b: t[a-1] += 1 else: t[b-1] += 1 for k in range(0,n-1): print(int(t[k]))
[["-", 0, 659, 12, 652, 3, 4, 0, 657, 17, 33], ["-", 0, 659, 12, 652, 3, 4, 0, 657, 12, 612]]
5
132
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll N, X, Y; ll NMAX = 2.0e3; cin >> N >> X >> Y; vector<ll> cnt(N); for (ll i = 1; i < N + 1; i++) { for (ll j = i; j < N + 1; j++) { ll a, b, c; a = abs(j - i); b = abs(X - i) + 1 + abs(Y - j); c = ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll N, X, Y; ll NMAX = 2.0e3; cin >> N >> X >> Y; vector<ll> cnt(N); for (ll i = 1; i < N + 1; i++) { for (ll j = i + 1; j < N + 1; j++) { ll a, b, c; a = abs(j - i); b = abs(X - i) + 1 + abs(Y - j); ...
[["+", 0, 7, 10, 43, 49, 50, 51, 16, 17, 72], ["+", 0, 7, 10, 43, 49, 50, 51, 16, 12, 13], ["-", 12, 16, 12, 2, 3, 4, 0, 16, 12, 22], ["+", 12, 16, 12, 2, 3, 4, 0, 16, 12, 22]]
1
183
#include <algorithm> #include <climits> #include <cmath> #include <iomanip> #include <iostream> #include <queue> #include <string> #include <vector> using namespace std; typedef long long ll; int main() { int n, x, y; cin >> n >> x >> y; vector<int> res(n - 1); for (int i = 0; i <= n - 1; i++) res[i] = 0; ...
#include <algorithm> #include <climits> #include <cmath> #include <iomanip> #include <iostream> #include <queue> #include <string> #include <vector> using namespace std; typedef long long ll; int main() { int n, x, y; cin >> n >> x >> y; vector<int> res(n - 1); for (int i = 0; i <= n - 2; i++) res[i] = 0; ...
[["-", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 8, 9, 0, 45], ["+", 0, 14, 8, 9, 0, 7, 8, 9, 0, 46]]
1
214
// Bismillahir Rahmanir Rahim #include <bits/stdc++.h> using namespace std; #define ll long long #define gcd(a, b) __gcd(a, b) s const int N = 2e5 + 10; const int inf = 1e9; const int mod = 1e9 + 7; int main(int argc, char const *argv[]) { /*#ifndef ONLINE_JUDGE freopen("input.txt","r",stdin); freopen("output.txt"...
// Bismillahir Rahmanir Rahim #include <bits/stdc++.h> using namespace std; #define ll long long #define gcd(a, b) __gcd(a, b) s const int N = 2e5 + 10; const int inf = 1e9; const int mod = 1e9 + 7; int main(int argc, char const *argv[]) { /*#ifndef ONLINE_JUDGE freopen("input.txt","r",stdin); freopen("output.txt"...
[["-", 31, 16, 31, 2, 3, 4, 0, 16, 12, 22], ["+", 31, 16, 31, 2, 3, 4, 0, 16, 12, 22]]
1
228
#include <bits/stdc++.h> using namespace std; int main() { int N, X, Y; cin >> N >> X >> Y; vector<int> count(N + 1); for (int i = 1; i <= N; i++) { for (int j = i; j <= N; j++) { int A, B, C, D; A = j - i; B = 1; if (j > Y) { C = j - Y; } else { C = Y - j; ...
#include <bits/stdc++.h> using namespace std; int main() { int N, X, Y; cin >> N >> X >> Y; vector<int> count(N + 1); for (int i = 1; i <= N; i++) { for (int j = i; j <= N; j++) { int A, B, C, D; A = j - i; B = 1; if (j > Y) { C = j - Y; } else { C = Y - j; ...
[["-", 8, 9, 0, 7, 15, 16, 12, 16, 17, 72], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
1
188
// shan61916 #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef double dll; #define mp make_pair #define pb push_back #define ff first #define ss second #define IOS \ ios::sync_with_stdio(false...
// shan61916 #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef double dll; #define mp make_pair #define pb push_back #define ff first #define ss second #define IOS \ ios::sync_with_stdio(false...
[["-", 31, 16, 31, 2, 3, 4, 0, 16, 31, 22], ["-", 31, 16, 31, 2, 3, 4, 0, 16, 17, 33], ["+", 31, 16, 31, 2, 3, 4, 0, 16, 17, 33], ["+", 31, 16, 31, 2, 3, 4, 0, 16, 12, 22]]
1
245
#include <bits/stdc++.h> using namespace std; long long p[10004]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n, x, y, k; cin >> n >> x >> y; for (long long i = 1; i < n; ++i) { for (long long j = 2; j <= n; ++j) { k = min(j - i, abs(x - i) + 1 + abs(y - j)); ...
#include <bits/stdc++.h> using namespace std; long long p[10004]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n, x, y, k; cin >> n >> x >> y; for (long long i = 1; i < n; ++i) { for (long long j = i + 1; j <= n; ++j) { k = min(j - i, abs(x - i) + 1 + abs(y - j...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 0, 7, 10, 43, 49, 50, 51, 16, 31, 22], ["+", 0, 7, 10, 43, 49, 50, 51, 16, 17, 72], ["+", 0, 7, 10, 43, 49, 50, 51, 16, 12, 13]]
1
150
n,x,y=map(int,input().split()) cnt=[0 for i in range(n)] for i in range(1,n+1): for j in range(i+1,n+1): a=min(abs(x-i),abs(y-i)) b=min(abs(x-j),abs(y-j)) l=min(j-i,a+b+y-x) cnt[l] += 1 for i in range(1,n): print(cnt[i])
n,x,y=map(int,input().split()) cnt=[0 for i in range(n)] for i in range(1,n+1): for j in range(i+1,n+1): a=min(abs(x-i),abs(y-i)) b=min(abs(x-j),abs(y-j)) l=min(j-i,a+b+1) cnt[l] += 1 for i in range(1,n): print(cnt[i])
[["-", 12, 652, 3, 4, 0, 657, 31, 657, 12, 22], ["-", 0, 662, 12, 652, 3, 4, 0, 657, 17, 33], ["-", 0, 662, 12, 652, 3, 4, 0, 657, 12, 22], ["+", 0, 662, 12, 652, 3, 4, 0, 657, 12, 612]]
5
131
n, x, y = map(int, input().split()) x = x-1 y = y-1 from collections import deque que = deque() INF = 10**5 seen = [[INF] * n for _ in range(n)] #import numpy as np for i in range(n): que.append(i) seen[i][i] = 0 #print('---', i) while len(que) > 0: t = que.popleft() step = [t-1, t+1] ...
n, x, y = map(int, input().split()) x = x-1 y = y-1 from collections import deque que = deque() INF = 10**5 seen = [[INF] * n for _ in range(n)] #import numpy as np for i in range(n): que.append(i) seen[i][i] = 0 #print('---', i) while len(que) > 0: t = que.popleft() step = [t-1, t+1] ...
[["-", 8, 196, 0, 57, 15, 679, 31, 666, 0, 22], ["+", 8, 196, 0, 57, 15, 679, 31, 666, 0, 612]]
5
251
#include <algorithm> #include <iomanip> #include <iostream> #include <string> #include <vector> typedef unsigned long long ULL; typedef long long LL; using namespace std; void process(); int main() { int N, X, Y; bool update; int i, j; cin >> N; int dis[N][N]; int dis_num[N]; for (i = 0; i < N; i++) {...
#include <algorithm> #include <iomanip> #include <iostream> #include <string> #include <vector> typedef unsigned long long ULL; typedef long long LL; using namespace std; void process(); int main() { int N, X, Y; bool update; int i, j; cin >> N; int dis[N][N]; int dis_num[N]; for (i = 0; i < N; i++) {...
[["+", 8, 9, 0, 7, 10, 11, 12, 16, 17, 33], ["+", 8, 9, 0, 7, 10, 11, 12, 16, 12, 13]]
1
473
N,X,Y = map(int, input().split()) #N <=2*10**3 #総当たりはN*(N-1) = 4*10**6 間に合う ans_dict = {i:0 for i in range(1,N+1)} for i in range(1,N+1): for j in range(i+1,N+1): #print(i,j) #ストレートで行くパターン straight = j - i #XYを経由するパターン throught_XY = min(abs(X-i),abs(Y-i)) + min(abs(X-j),ab...
N,X,Y = map(int, input().split()) #N <=2*10**3 #総当たりはN*(N-1) = 4*10**6 間に合う ans_dict = {i:0 for i in range(1,N+1)} for i in range(1,N+1): for j in range(i+1,N+1): #print(i,j) #ストレートで行くパターン straight = j-i #XYを経由するパターン throught_XY = min(abs(X-i),abs(Y-i))+min(abs(X-j),abs(Y-...
[["-", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
143
#include <bits/stdc++.h> #define mes(a, b) memset(a, b, sizeof a) #define pb push_back typedef unsigned long long int ull; typedef long long int ll; const int maxn = 2e5 + 20; const int maxm = 1e5 + 10; const ll mod = 1e9 + 7; const ll INF = 1e18 + 100; const int inf = 0x3f3f3f3f; const double pi = acos(-1.0); const do...
#include <bits/stdc++.h> #define mes(a, b) memset(a, b, sizeof a) #define pb push_back typedef unsigned long long int ull; typedef long long int ll; const int maxn = 2e5 + 20; const int maxm = 1e5 + 10; const ll mod = 1e9 + 7; const ll INF = 1e18 + 100; const int inf = 0x3f3f3f3f; const double pi = acos(-1.0); const do...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18]]
1
382
#include "bits/stdc++.h" #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; int getdistance(int i, int j, int N, int X, int Y) { int result = 0; if (i <= X) { if (j < Y) { result = min(j - i, X - i + Y - j + 1); } else { result = X - i + j - Y + 1; } } else if (i <= Y) { ...
#include "bits/stdc++.h" #define rep(i, n) for (int i = 0; i < n; i++) using namespace std; int getdistance(int i, int j, int N, int X, int Y) { int result = 0; if (i <= X) { if (j < Y) { result = min(j - i, X - i + Y - j + 1); } else { result = X - i + j - Y + 1; } } else if (i <= Y) { ...
[["-", 8, 9, 0, 7, 15, 16, 12, 16, 17, 72], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
1
291
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> #include <vector> using namespace std; int ans[100005]; int n, x, y; int main() { cin >> n >> x >> y; for (int i = 1; i < n; i++) { for (int j = i + 1; j <= n; j++) { ans[min(abs(i - j), min(abs(i - x) + abs(j - x), ...
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> #include <vector> using namespace std; int ans[100005]; int n, x, y; int main() { cin >> n >> x >> y; for (int i = 1; i < n; i++) { for (int j = i + 1; j <= n; j++) { ans[min(abs(i - j), min(abs(i - x) + abs(j - x), ...
[["+", 8, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
1
170
#include <bits/stdc++.h> #define ll long long #define ull unsigned long long using namespace std; int main() { ll K; cin >> K; queue<ll> q; for (int ii = 1; ii < 10; ++ii) { q.push(ii); } ll cnt = 0; ll ans; while (cnt <= K) { ll val = q.front(); q.pop(); ll val1 = val % 10; // 1の位 ...
#include <bits/stdc++.h> #define ll long long #define ull unsigned long long using namespace std; int main() { ll K; cin >> K; queue<ll> q; for (int ii = 1; ii < 10; ++ii) { q.push(ii); } ll cnt = 0; ll ans; while (cnt < K) { ll val = q.front(); q.pop(); ll val1 = val % 10; // 1の位 ...
[["-", 8, 9, 0, 52, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 17, 18]]
1
159
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <queue> #include <string> using namespace std; int main() { int K; cin >> K; long long runrun; queue<long long> Q; for (int i = 1; i < 10; i++) { Q.push(i); } for (int i = 0; i < K; i++) { runrun = Q.front(); ...
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <queue> #include <string> using namespace std; int main() { int K; cin >> K; long long runrun; queue<long long> Q; for (int i = 1; i < 10; i++) { Q.push(i); } for (int i = 0; i < K; i++) { runrun = Q.front(); ...
[["+", 3, 4, 0, 16, 31, 16, 12, 16, 17, 109], ["+", 3, 4, 0, 16, 31, 16, 12, 16, 12, 13], ["+", 0, 2, 3, 4, 0, 16, 12, 16, 17, 109], ["+", 0, 2, 3, 4, 0, 16, 12, 16, 12, 13]]
1
157
# from sys import stdin import sys global cnt1 def bts(A, cnt, max): # print(A) if cnt == max: global cnt1 cnt1 = cnt1+1 if cnt1 == K: print(A) sys.exit() return cnt = cnt+1 if A % 10 == 0: bts(A*10+(A % 10), cnt, max) bts(A*10+(A...
# from sys import stdin import sys global cnt1 def bts(A, cnt, max): # print(A) if cnt == max: global cnt1 cnt1 = cnt1+1 if cnt1 == K: print(A) sys.exit() return cnt = cnt+1 if A % 10 == 0: bts(A*10+(A % 10), cnt, max) bts(A*10+(A...
[["-", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612], ["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612]]
5
254
#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 ordered_set tree<int, null_type,less<int>, // rb_tree_tag,tree_order_statistics_node_update> #define ll long long int #define ld long double #defin...
#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 ordered_set tree<int, null_type,less<int>, // rb_tree_tag,tree_order_statistics_node_update> #define ll long long int #define ld long double #defin...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["-", 0, 57, 64, 9, 0, 1, 0, 16, 12, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 16, 12, 22]]
1
280
from collections import deque k = 9 #+ (9*3-1) count = 0 q = deque(range(1,10)) while count < k: l = q.popleft() resid = l % 10 if resid != 0: q.append(l*10 + resid - 1) q.append(l*10 + resid) if resid != 9: q.append(l*10 + resid + 1) count += 1 print(l)
from collections import deque k = int(input()) count = 0 q = deque(range(1,10)) while count < k: l = q.popleft() resid = l % 10 if resid != 0: q.append(l*10 + resid - 1) q.append(l*10 + resid) if resid != 9: q.append(l*10 + resid + 1) count += 1 print(l)
[["-", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612], ["+", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 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, 25], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]]
5
90
from collections import deque stdin = sys.stdin read_int = lambda : list(map(int,stdin.readline().split())) K = read_int()[0] q = deque() for i in range(1, 10): q.append(i) def solve(): for _ in range(K - 1): x = q.popleft() if x % 10 != 0: q.append(10 * x + (x % 10 - 1)) ...
from collections import deque import sys stdin = sys.stdin read_int = lambda : list(map(int,stdin.readline().split())) K = read_int()[0] q = deque() for i in range(1, 10): q.append(i) def solve(): for _ in range(K - 1): x = q.popleft() if x % 10 != 0: q.append(10 * x + (x % 10 - ...
[["+", 36, 36, 36, 36, 0, 656, 0, 596, 0, 487], ["+", 36, 36, 0, 656, 0, 596, 141, 673, 0, 22], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 25], ["-", 0, 14, 8, 196, 0, 1, 0, 652, 63, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24]]
5
164
from collections import deque q=deque() N=int(input()) for i in range(1,10): q.append(i) for _ in range(N-1): x=q.popleft() if x%10!=0: q.append(10*x+(x%10)-1) q.append(10*x+(x%10)) if x%10!=9: q.append(10*x+(x%10)+1) print(q.poplefr())
from collections import deque q=deque() N=int(input()) for i in range(1,10): q.append(i) for _ in range(N-1): x=q.popleft() if x%10!=0: q.append(10*x+(x%10-1)) q.append(10*x+(x%10)) if x%10!=9: q.append(10*x+(x%10+1)) print(q.popleft())
[["-", 3, 4, 0, 657, 31, 657, 12, 23, 0, 25], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 25], ["+", 0, 652, 3, 4, 0, 657, 12, 23, 0, 25], ["-", 0, 652, 3, 4, 0, 652, 63, 319, 319, 22], ["+", 0, 652, 3, 4, 0, 652, 63, 319, 319, 22]]
5
118
import math from collections import defaultdict ml=lambda:map(int,input().split()) ll=lambda:list(map(int,input().split())) ii=lambda:int(input()) ip=lambda:input() """========main code===============""" x=ii() lol=[1,2,3,4,5,6,7,8,9] ans=9 if(x>9): for i in lol: k=str(i) a=int(k[len(k)-1]) ...
import math from collections import defaultdict ml=lambda:map(int,input().split()) ll=lambda:list(map(int,input().split())) ii=lambda:int(input()) ip=lambda:input() """========main code===============""" x=ii() lol=[1,2,3,4,5,6,7,8,9] ans=9 if(x>9): for i in lol: k=str(i) a=int(k[len(k)-1]) ...
[["+", 0, 1, 0, 652, 3, 4, 0, 206, 51, 22], ["+", 0, 1, 0, 652, 3, 4, 0, 206, 0, 70], ["+", 0, 1, 0, 652, 3, 4, 0, 206, 0, 73]]
5
245
from collections import deque K=int(input()) todo=deque(list(map(str,range(1,10)))) count=0 while todo: num=todo.popleft() count+=1 if count==k: print(num) exit() base=int(num[-1]) n1=base-1 if n1!=-1: todo.append(num+str(n1)) n2=base todo.append(nu...
from collections import deque K=int(input()) todo=deque(list(map(str,range(1,10)))) count=0 while todo: num=todo.popleft() count+=1 if count==K: print(num) exit() base=int(num[-1]) n1=base-1 if n1!=-1: todo.append(num+str(n1)) n2=base todo.append(nu...
[["-", 0, 52, 8, 196, 0, 57, 15, 666, 0, 22], ["+", 0, 52, 8, 196, 0, 57, 15, 666, 0, 22]]
5
126
#include <bits/stdc++.h> using namespace std; using ll = long long; signed main() { ll k; cin >> k; vector<ll> a(10); iota(a.begin(), a.end(), 0); for (ll i = 1; a.size() < k; i++) { ll last = a[i] % 10, next = a[i] * 10 + last; if (last) a.push_back(next - 1); a.push_back(next); if (la...
#include <bits/stdc++.h> using namespace std; using ll = long long; signed main() { ll k; cin >> k; vector<ll> a(10); iota(a.begin(), a.end(), 0); for (ll i = 1; a.size() <= k; i++) { ll last = a[i] % 10, next = a[i] * 10 + last; if (last) a.push_back(next - 1); a.push_back(next); if (l...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]]
1
136
def main(argv): k = int(sys.stdin.readline().rstrip("\n")) if k < 10: return print(k) d = {i: [i] for i in range(10)} counter = 9 n = 1 while counter < k: next_d = {} candidates = d[0] candidates.extend(d[1]) next_d[0] = sorted([c for c in set(candidates)...
import sys def main(argv): k = int(sys.stdin.readline().rstrip("\n")) if k < 10: return print(k) d = {i: [i] for i in range(10)} counter = 9 n = 1 while counter < k: next_d = {} candidates = d[0] candidates.extend(d[1]) next_d[0] = sorted([c for c in set...
[["+", 36, 36, 36, 36, 0, 656, 0, 596, 0, 487], ["+", 36, 36, 0, 656, 0, 596, 141, 673, 0, 22]]
5
233
#include <algorithm> #include <cassert> #include <cstdio> #include <cstdlib> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define repi(i, a, b) for (int i = (a); i < (b); ++i) #define rep(i, a) repi(i, 0,...
#include <algorithm> #include <cassert> #include <cstdio> #include <cstdlib> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define repi(i, a, b) for (int i = (a); i < (b); ++i) #define rep(i, a) repi(i, 0,...
[["-", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22], ["-", 0, 14, 8, 9, 0, 1, 0, 11, 17, 110], ["-", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
306
#include <bits/stdc++.h> using namespace std; #define rep(i, s, n) for (int i = (int)s; i < (int)n; i++) #define ll long long #define ld long double #define pb push_back #define eb emplace_back #define All(x) x.begin(), x.end() #define Range(x, i, j) x.begin() + i, x.begin() + j #define lbidx(x, y) lower_bound(x.begin...
#include <bits/stdc++.h> using namespace std; #define rep(i, s, n) for (int i = (int)s; i < (int)n; i++) #define ll long long #define ld long double #define pb push_back #define eb emplace_back #define All(x) x.begin(), x.end() #define Range(x, i, j) x.begin() + i, x.begin() + j #define lbidx(x, y) lower_bound(x.begin...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
1
666
# solution k=int(input()) from collections import deque todo = deque([i for i in range(1, 10)]) count = 0 while len(todo) > 0: value = todo.popleft() seen.append(value) value_digit1 = value % 10 count += 1 if count == k: print(value) break if value_digit1==0: todo.appen...
# solution k=int(input()) from collections import deque todo = deque([i for i in range(1, 10)]) count = 0 while len(todo) > 0: value = todo.popleft() value_digit1 = value % 10 count += 1 if count == k: print(value) break if value_digit1==0: todo.append(10*value) tod...
[["-", 8, 196, 0, 1, 0, 652, 63, 319, 500, 22], ["-", 8, 196, 0, 1, 0, 652, 63, 319, 0, 131], ["-", 8, 196, 0, 1, 0, 652, 63, 319, 319, 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
156
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; set<ll> v{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; ll c = 0; int g; void rec(int n, int k) { if (k == 0) { v.insert(c); return; } else if (k < g) { if (n > 0) { c += (n - 1) * pow(10, k - 1); rec(n -...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; set<ll> v{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; ll c = 0; int g; void rec(int n, int k) { if (k == 0) { v.insert(c); return; } else if (k < g) { if (n > 0) { c += (n - 1) * pow(10, k - 1); rec(n -...
[["+", 0, 52, 15, 339, 51, 16, 12, 16, 17, 72], ["+", 0, 52, 15, 339, 51, 16, 12, 16, 12, 13]]
1
498
from collections import deque K = int(input()) tree = deque([[0, i] for i in range(1, 10)]) i = 0 cnt = 9 while cnt <= K: n = tree[i][1] if n > 0: tree.append([i, n - 1]) cnt += 1 tree.append([i, n]) cnt += 1 if n < 9: tree.append([i, n + 1]) cnt += 1 i += 1 a...
from collections import deque K = int(input()) tree = deque([[-1, i] for i in range(1, 10)]) i = 0 cnt = 9 while cnt <= K: n = tree[i][1] if n > 0: tree.append([i, n - 1]) cnt += 1 tree.append([i, n]) cnt += 1 if n < 9: tree.append([i, n + 1]) cnt += 1 i += 1 ...
[["-", 12, 652, 3, 4, 0, 658, 8, 634, 0, 612], ["+", 3, 4, 0, 658, 8, 634, 0, 664, 17, 33], ["+", 3, 4, 0, 658, 8, 634, 0, 664, 28, 612], ["-", 0, 52, 8, 196, 0, 57, 15, 666, 0, 612], ["+", 8, 196, 0, 57, 15, 666, 0, 664, 17, 33], ["+", 8, 196, 0, 57, 15, 666, 0, 664, 28, 612]]
5
147
## 解説をみての答え from collections import deque q = deque(range(1,10)) K = int(input()) for i in range(K): x = q.popleft() r = x % 10 if r != 0: q.append((10 * x) + (r - 1)) q.append((10 * x) + r) if r != 9: q.put((10 * x) + (r + 1)) print(x)
from collections import deque q = deque(range(1,10)) K = int(input()) for i in range(K): x = q.popleft() r = x % 10 if r != 0: q.append((10 * x) + (r - 1)) q.append((10 * x) + r) if r != 9: q.append((10 * x) + (r + 1)) print(x)
[["-", 64, 196, 0, 1, 0, 652, 63, 319, 319, 22], ["+", 64, 196, 0, 1, 0, 652, 63, 319, 319, 22]]
5
102
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { static BufferedReader reader; final static boolean MODE_DEBUG = true; // static field here public static void main(String[] args) { // TODO Auto-generated method stub reader = new Buffered...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { static BufferedReader reader; final static boolean MODE_DEBUG = true; // static field here public static void main(String[] args) { // TODO Auto-generated method stub reader = new Buffered...
[["-", 0, 195, 8, 196, 0, 503, 49, 200, 51, 499], ["+", 0, 195, 8, 196, 0, 503, 49, 200, 51, 499], ["+", 0, 1, 0, 492, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 492, 3, 4, 0, 16, 12, 499]]
3
706
def lower(upper): if upper==9: return [8,9] elif upper==0: return [0,1] else: return [upper-1,upper,upper+1] def numerize(a): return sum([a[i]*(10**i) for i in range(len(a))]) def getRunruns(digit): if digit==1: return [(i,) for i in range(10)] elif digit==2: ...
def lower(upper): if upper==9: return [8,9] elif upper==0: return [0,1] else: return [upper-1,upper,upper+1] def numerize(a): return sum([a[i]*(10**i) for i in range(len(a))]) def getRunruns(digit): if digit==1: return [(i,) for i in range(10)] elif digit==2: ...
[["+", 0, 656, 0, 52, 15, 666, 0, 657, 17, 72], ["+", 0, 656, 0, 52, 15, 666, 0, 657, 12, 612]]
5
273
#include <bits/stdc++.h> #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define FORR(i, b, a) for (int i = (b)-1; i >= 0; --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 ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr) #define SORT(v) ...
#include <bits/stdc++.h> #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define FORR(i, b, a) for (int i = (b)-1; i >= 0; --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 ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr) #define SORT(v) ...
[["+", 3, 4, 0, 16, 31, 16, 12, 16, 17, 109], ["+", 3, 4, 0, 16, 31, 16, 12, 16, 12, 13], ["+", 0, 2, 3, 4, 0, 16, 12, 16, 17, 109], ["+", 0, 2, 3, 4, 0, 16, 12, 16, 12, 13]]
1
227
#include <bits/stdc++.h> #include <math.h> #include <regex> using namespace std; typedef long long ll; typedef long double ld; #define rep(i, n) for (int i = 0; i < (int)(n); i++) const ll mod = 1000000007; const int INF = 1001001001; const ll LINF = 1001001001001001001; int main() { ll k; cin >> k; queue<ll> q;...
#include <bits/stdc++.h> #include <math.h> #include <regex> using namespace std; typedef long long ll; typedef long double ld; #define rep(i, n) for (int i = 0; i < (int)(n); i++) const ll mod = 1000000007; const int INF = 1001001001; const ll LINF = 1001001001001001001; int main() { ll k; cin >> k; queue<ll> q;...
[["-", 0, 2, 3, 4, 0, 16, 31, 16, 12, 22], ["+", 0, 2, 3, 4, 0, 16, 31, 16, 12, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22]]
1
184
import queue k = int(input()) q = queue.Queue() for i in range(1,10): q.put(i) for i in range(k): x = q.get() p = 10 * x m = x % 10 if not p == 0: q.put(p + m - 1) q.put(p + m) if not p == 9: q.put(p + m + 1) print(x)
import queue k = int(input()) q = queue.Queue() for i in range(1,10): q.put(i) for i in range(k): x = q.get() p = 10 * x m = x % 10 if not m == 0: q.put(p + m - 1) q.put(p + m) if not m == 9: q.put(p + m + 1) print(x)
[["-", 8, 196, 0, 57, 15, 681, 28, 666, 0, 22], ["+", 8, 196, 0, 57, 15, 681, 28, 666, 0, 22]]
5
102
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> using namespace std; #define ll long long #define rep(i, s, n) for (int i = s; i < n; i++) int main() { ll k; cin >> k; queue<ll> que; rep(i, 1, 10) { que.push(i); } ll...
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> using namespace std; #define ll long long #define rep(i, s, n) for (int i = s; i < n; i++) int main() { ll k; cin >> k; queue<ll> que; rep(i, 1, 10) { que.push(i); } ll...
[["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
1
178
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using vi = vector<int>; using vll = vector<ll>; using P = pair<int, int>; const int INF = 1e9; const ll INFLL = 1e18; const int MOD = 1e9 + 7; const int NIL = -1; const ld PI = acosl(-1); #define rep(i, n) for (int i = 0; i <...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using vi = vector<int>; using vll = vector<ll>; using P = pair<int, int>; const int INF = 1e9; const ll INFLL = 1e18; const int MOD = 1e9 + 7; const int NIL = -1; const ld PI = acosl(-1); #define rep(i, n) for (int i = 0; i <...
[["-", 3, 4, 0, 16, 31, 16, 31, 16, 31, 13], ["+", 3, 4, 0, 16, 31, 16, 31, 16, 31, 13], ["-", 0, 2, 3, 4, 0, 16, 31, 16, 31, 13], ["+", 0, 2, 3, 4, 0, 16, 31, 16, 31, 13]]
1
330
#include <bits/stdc++.h> #define re register #define int long long using namespace std; inline int read() { re int ans = 0; re bool f = 1; re char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = 0; ch = getchar(); } while (ch >= '0' && ch <= '9') { ans = (ans << 3) + (an...
#include <bits/stdc++.h> #define re register #define int long long using namespace std; inline int read() { re int ans = 0; re bool f = 1; re char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = 0; ch = getchar(); } while (ch >= '0' && ch <= '9') { ans = (ans << 3) + (an...
[["-", 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, 17, 19], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18]]
1
275
import numpy as np k = int(input()) # ルンルン数で無くても二分探索を怖れない def check(n): digits = [] while n: n, m = divmod(n, 10) digits.append(m) digits.reverse() dp = np.zeros(10, dtype=np.int64) dp[1:digits[0]] = 1 edge = digits[0] for d in digits[1:]: odp = dp.copy() ...
import numpy as np k = int(input()) # ルンルン数で無くても二分探索を怖れない def check(n): digits = [] while n: n, m = divmod(n, 10) digits.append(m) digits.reverse() dp = np.zeros(10, dtype=np.int64) dp[1:digits[0]] = 1 edge = digits[0] for d in digits[1:]: odp = dp.copy() ...
[["+", 0, 677, 31, 206, 206, 663, 0, 652, 63, 22], ["+", 31, 206, 206, 663, 0, 652, 3, 4, 0, 24], ["+", 31, 206, 206, 663, 0, 652, 3, 4, 0, 612], ["+", 31, 206, 206, 663, 0, 652, 3, 4, 0, 21], ["+", 31, 206, 206, 663, 0, 652, 3, 4, 0, 25]]
5
245
#include <bits/stdc++.h> using namespace std; #define rep(i, c) for (ll i = 0; i < (ll)c; i++) #define ll long long const int inf = 1000000000; // 10^9 int main() { ll k, i = 0, now; cin >> k; queue<ll> q; for (int j = 1; j < 10; j++) q.push(j); if (k == 1) cout << 1 << endl; else { while (k ...
#include <bits/stdc++.h> using namespace std; #define rep(i, c) for (ll i = 0; i < (ll)c; i++) #define ll long long const int inf = 1000000000; // 10^9 int main() { ll k, i = 0, now; cin >> k; queue<ll> q; for (int j = 1; j < 10; j++) q.push(j); if (k == 1) cout << 1 << endl; else { while (k ...
[["-", 8, 9, 0, 57, 75, 76, 0, 9, 0, 46], ["+", 8, 9, 0, 57, 75, 76, 0, 9, 0, 46]]
1
184
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { int K; cin >> K; priority_queue<ll, vector<ll>, greater<ll>> q; for (int i = 1; i < 10; i++) { q.emplace(i); } int count = 0; ll ans; while (true) { ll val = q.top(); q.pop(); count++; if (count == K) {...
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { int K; cin >> K; priority_queue<ll, vector<ll>, greater<ll>> q; for (int i = 1; i < 10; i++) { q.emplace(i); } int count = 0; ll ans; while (true) { ll val = q.top(); q.pop(); count++; if (count == K) {...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22]]
1
175
#include <algorithm> #include <iostream> #include <queue> using namespace std; typedef long long ll; int main(int argc, char *argv[]) { int K; queue<ll> q; cin >> K; for (int i = 1; i <= 9; i++) { q.push(ll(i)); } for (int i = 0; i < K - 1; i++) { ll x = q.front(); q.pop(); if (x % 10 ...
#include <algorithm> #include <iostream> #include <queue> using namespace std; typedef long long ll; int main(int argc, char *argv[]) { int K; queue<ll> q; cin >> K; for (int i = 1; i <= 9; i++) { q.push(ll(i)); } for (int i = 0; i < K - 1; i++) { ll x = q.front(); q.pop(); if (x % 10 ...
[["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 2, 3, 4, 0, 16, 12, 16, 31, 22], ["+", 0, 2, 3, 4, 0, 16, 12, 16, 17, 109], ["+", 0, 2, 3, 4, 0, 16, 12, 16, 12, 13]]
1
173
#include <bits/stdc++.h> using namespace std; int main() { int K; cin >> K; priority_queue<long long int> Q; for (int i = 1; i < 10; i++) Q.push(i); int X = 0; for (int i = 1; i <= K; i++) { X = Q.top(); Q.pop(); if (X % 10 == 0) { Q.push(10 * X); Q.push(10 * X + 1); } else ...
#include <bits/stdc++.h> using namespace std; int main() { int K; cin >> K; queue<long long int> Q; for (int i = 1; i < 10; i++) Q.push(i); long long int X = 0; for (int i = 1; i <= K; i++) { X = Q.front(); Q.pop(); if (X % 10 == 0) { Q.push(10 * X); Q.push(10 * X + 1); } el...
[["-", 0, 14, 8, 9, 0, 43, 39, 344, 141, 78], ["+", 0, 14, 8, 9, 0, 43, 39, 344, 141, 78], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["-", 0, 1, 0, 11, 12, 2, 63, 118, 119, 120], ["+", 0, 1, 0, 11, 12, 2, 63, 118, 119, 120]]
1
198
#include <bits/stdc++.h> using namespace std; int main() { int64_t k; cin >> k; queue<int64_t> q; for (int64_t i = 1; i <= 9; i++) { q.emplace(i); } for (int64_t i = 1; i <= k; i++) { int64_t x = q.front(); q.pop(); for (int64_t d = max<int64_t>(0, x % 10 - 1); d <= min<int64_t>...
#include <bits/stdc++.h> using namespace std; int main() { int64_t k; cin >> k; queue<int64_t> q; for (int64_t i = 1; i <= 9; i++) { q.emplace(i); } for (int64_t i = 0; i < k - 1; i++) { int64_t x = q.front(); q.pop(); for (int64_t d = max<int64_t>(0, x % 10 - 1); d <= min<int64...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
1
143
from collections import deque k = int(input()) d = deque() d += [1,2,3,4,5,6,7,8,9] for i in range(k): # print(d, now) now = d.popleft() if now%10 != 0: d.append(10 * now + now % 10 - 1) d.append(10 * now + now % 10) if now%10 != 9: d.append(10 * now + now % 10 + 1) print(k, now)
from collections import deque k = int(input()) d = deque() d += [1,2,3,4,5,6,7,8,9] for i in range(k): # print(d, now) now = d.popleft() if now%10 != 0: d.append(10 * now + now % 10 - 1) d.append(10 * now + now % 10) if now%10 != 9: d.append(10 * now + now % 10 + 1) print(now)
[["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 21]]
5
114
from collections import deque K = int(input()) Q = list(range(1, 10)) for i in range(K): x = Q[i] y = x%10 if y != 0: Q.append(10*x + y-1) Q.append(10*x + y) if y != 9: Q.append(10*x + y+1) print(Q[K])
from collections import deque K = int(input()) Q = list(range(1, 10)) for i in range(K): x = Q[i] y = x%10 if y != 0: Q.append(10*x + y-1) Q.append(10*x + y) if y != 9: Q.append(10*x + y+1) print(Q[K-1])
[["+", 0, 652, 3, 4, 0, 206, 206, 657, 17, 33], ["+", 0, 652, 3, 4, 0, 206, 206, 657, 12, 612]]
5
93
import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int k = sc.nextInt(); List<Long> que = new ArrayList<>(); for (int i = 1; i < 10; i++) { que.add((long)i); } f...
import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int k = sc.nextInt(); List<Long> que = new ArrayList<>(); for (int i = 1; i < 10; i++) { que.add((long)i); } f...
[["+", 3, 4, 0, 492, 3, 4, 0, 16, 17, 33], ["+", 3, 4, 0, 492, 3, 4, 0, 16, 12, 499]]
3
198
//参考:http://ehafib.hatenablog.com/entry/2015/12/23/164517 //インクルード #include <algorithm> //sort,二分探索,など #include <bitset> //固定長bit集合 #include <cmath> //pow,logなど #include <complex> //複素数 #include <deque> //両端アクセスのキュー #include <functional> //sortのgreater #include <iomanip> //setp...
//参考:http://ehafib.hatenablog.com/entry/2015/12/23/164517 //インクルード #include <algorithm> //sort,二分探索,など #include <bitset> //固定長bit集合 #include <cmath> //pow,logなど #include <complex> //複素数 #include <deque> //両端アクセスのキュー #include <functional> //sortのgreater #include <iomanip> //setp...
[["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 2, 3, 4, 0, 16, 12, 23, 0, 24], ["+", 3, 4, 0, 16, 12, 23, 0, 16, 31, 22], ["+", 3, 4, 0, 16, 12, 23, 0, 16, 17, 109], ["+", 3, 4, 0, 16, 12, 23, 0, 16, 12, 13], ["+", 0, 2, 3, 4, 0, 16, 12, 23, 0, 25]]
1
335
import queue K = int(input()) A = queue.Queue() for i in range(1, 10): A.put(i) num = 0 while num < K: emp = A.get() var = emp % 10 if var != 0: A.put(emp*10+var-1) A.put(10*emp) if var != 9: A.put(emp*10+var+1) num += 1 print(e...
import queue K = int(input()) A = queue.Queue() for i in range(1, 10): A.put(i) num = 0 while num < K: emp = A.get() var = emp % 10 if var != 0: A.put(emp*10+var-1) A.put(10*emp+var) if var != 9: A.put(emp*10+var+1) num += 1 pri...
[["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 22]]
5
102
from collections import deque k=int(input()) q=deque(list(range(1, 10))) ans,x,y=0,0,0 for i in range(k): ans=q.popleft() y=ans%10 x=ans*10+y if y != 0: q.append(tmp-1) q.append(tmp) if y != 9: q.append(tmp+1) print(ans)
from collections import deque k=int(input()) q=deque(list(range(1, 10))) ans,x,y=0,0,0 for i in range(k): ans=q.popleft() y=ans%10 x=ans*10+y if y != 0: q.append(x-1) q.append(x) if y != 9: q.append(x+1) print(ans)
[["-", 0, 1, 0, 652, 3, 4, 0, 657, 31, 22], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 31, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["+", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22]]
5
100
#include <bits/stdc++.h> using namespace std; #define LL long long typedef pair<int, int> pii; template <typename T> inline void read(T &x) { static char _c; static bool _f; x = 0; _f = 0; _c = getchar(); while (_c < '0' || '9' < _c) { if (_c == '-') _f = true; _c = getchar(); } while ...
#include <bits/stdc++.h> using namespace std; #define LL long long typedef pair<int, int> pii; template <typename T> inline void read(T &x) { static char _c; static bool _f; x = 0; _f = 0; _c = getchar(); while (_c < '0' || '9' < _c) { if (_c == '-') _f = true; _c = getchar(); } while ...
[["+", 64, 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
685
N, X, Y = map(int, input().split()) ans = [0] * (N - 1) X, Y = X - 1, Y - 1 Z = Y - X - 1 for i in range(N): if i <= X: for j in range(i + 1, Y): p = min(j - i - 1, abs(i - X) + Y - j) ans[p] += 1 for l in range(Y, N): ans[l - i - Z - 1] += 1 elif (X < i) and (i < Y - 1): for j...
N, X, Y = map(int, input().split()) ans = [0] * (N - 1) X, Y = X - 1, Y - 1 Z = Y - X - 1 for i in range(N): if i <= X: for j in range(i + 1, Y): p = min(j - i - 1, abs(i - X) + Y - j) ans[p] += 1 for l in range(Y, N): ans[l - i - Z - 1] += 1 elif (X < i) and (i < Y - 1): for j...
[["-", 0, 7, 12, 652, 3, 4, 0, 657, 31, 22], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612], ["+", 64, 196, 0, 7, 12, 652, 3, 4, 0, 22]]
5
223
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); int c = sc.nextInt(); int[] in = new int[a]; for (int i = 1; i < a; i++) { for (int j = i + 1; j < a + 1; j++) { in[Ma...
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); int c = sc.nextInt(); int[] in = new int[a - 1]; for (int i = 1; i < a; i++) { for (int j = i + 1; j < a + 1; j++) { i...
[["+", 49, 200, 51, 227, 497, 505, 0, 16, 17, 33], ["+", 49, 200, 51, 227, 497, 505, 0, 16, 12, 499], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 12, 499]]
3
180
#include <bits/stdc++.h> using namespace std; typedef long long ll; vector<int> to[2010]; int kyori[2010][2010]; int main(void) { for (int i = 0; i < 2010; i++) { for (int j = 0; j < 2010; j++) kyori[i][j] = -1; } int n, X, y; cin >> n >> X >> y; for (int i = 1; i <= n - 1; i++) { to[i].push_b...
#include <bits/stdc++.h> using namespace std; typedef long long ll; vector<int> to[2010]; int kyori[2010][2010]; int main(void) { for (int i = 0; i < 2010; i++) { for (int j = 0; j < 2010; j++) kyori[i][j] = -1; } int n, X, y; cin >> n >> X >> y; for (int i = 1; i <= n - 1; i++) { to[i].push_b...
[["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
1
349
#include <bits/stdc++.h> #define fr first using namespace std; // vector tuple solution int main() { int n, x, y; cin >> n >> x >> y; // dist -- y-x-1++ vector<int> dist(n, 0); for (int i = 1; i < n; i++) { for (int j = i + 1; j <= n; j++) { if (i >= x && i < y) { if (j >= y) dist...
#include <bits/stdc++.h> #define fr first using namespace std; // vector tuple solution int main() { int n, x, y; cin >> n >> x >> y; // dist -- y-x-1++ vector<int> dist(n, 0); for (int i = 1; i < n; i++) { for (int j = i + 1; j <= n; j++) { if (i >= x && i < y) { if (j >= y) dist...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18]]
1
241
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for (int i = 0; i < (n); i++) typedef long long ll; int main(int argc, char const *argv[]) { cin.tie(0); ios::sync_with_stdio(false); int N, X, Y; cin >> N >> X >> Y; vector<int> res(N - 1, 0); REP(i, N) { REP(j, N) { if (j <= i) ...
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for (int i = 0; i < (n); i++) typedef long long ll; int main(int argc, char const *argv[]) { cin.tie(0); ios::sync_with_stdio(false); int N, X, Y; cin >> N >> X >> Y; vector<int> res(N, 0); REP(i, N) { REP(j, N) { if (j <= i) ...
[["-", 0, 43, 49, 50, 51, 4, 0, 16, 17, 33], ["-", 0, 43, 49, 50, 51, 4, 0, 16, 12, 13]]
1
171
#include "bits/stdc++.h" using namespace std; vector<int> dis; int main() { int n, x, y; cin >> n >> x >> y; dis = vector<int>(n, 0); for (int i = 0; i < n - 1; i++) { for (int j = i + 1; j < n; j++) { int d; if (j <= x - 1) { d = j - i; } else if (i <= x - 1 && j <= y - 1) { ...
#include "bits/stdc++.h" using namespace std; vector<int> dis; int main() { int n, x, y; cin >> n >> x >> y; dis = vector<int>(n, 0); for (int i = 0; i < n - 1; i++) { for (int j = i + 1; j < n; j++) { int d; if (j <= x - 1) { d = j - i; } else if (i <= x - 1 && j <= y - 1) { ...
[["-", 15, 339, 51, 16, 31, 16, 12, 16, 31, 22], ["+", 15, 339, 51, 16, 31, 16, 12, 16, 31, 22], ["-", 15, 339, 51, 16, 31, 16, 12, 16, 12, 22], ["+", 15, 339, 51, 16, 31, 16, 12, 16, 12, 13]]
1
331
#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } #define rep(i, n) for (int i = 0; i...
//#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } #define rep(i, n) for (int i = 0;...
[["-", 36, 36, 36, 36, 0, 30, 0, 58, 0, 148], ["-", 36, 36, 36, 36, 0, 30, 0, 58, 141, 22]]
1
535
#include <algorithm> #include <array> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <cstdint> #include <cstdio> #include <cstring> #include <deque> #include <iostream> #include <iterator> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <tu...
#include <algorithm> #include <array> #include <bitset> #include <cassert> #include <cmath> #include <complex> #include <cstdint> #include <cstdio> #include <cstring> #include <deque> #include <iostream> #include <iterator> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <tu...
[["-", 31, 16, 12, 2, 3, 4, 0, 16, 12, 22], ["+", 31, 16, 12, 2, 3, 4, 0, 16, 12, 22]]
1
227
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define rep2(i, a, n) for (ll i = a; i < (ll)(n); i++) #define memi cout << endl #define kono(n) cout << fixed << setprecision(n) #define all(c) (c).begin(), (c).end() #define pb push_back #define hina...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define rep2(i, a, n) for (ll i = a; i < (ll)(n); i++) #define memi cout << endl #define kono(n) cout << fixed << setprecision(n) #define all(c) (c).begin(), (c).end() #define pb push_back #define hina...
[["+", 8, 9, 0, 9, 0, 1, 0, 27, 28, 22], ["+", 8, 9, 0, 9, 0, 1, 0, 27, 17, 68], ["+", 0, 14, 8, 9, 0, 9, 0, 1, 0, 35]]
1
210
#include <bits/stdc++.h> #define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; i++) #define FORR(i, n) for (ll i = (ll)n - 1LL; i >= 0LL; i--) #define rep(i, n) FOR(i, 0, n) #define ALL(x) ((x).begin(), (x).end()) using namespace std; using ll = long long; template <typename T> using V = vector<T>; constexpr int Mod = 99...
#include <bits/stdc++.h> #define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; i++) #define FORR(i, n) for (ll i = (ll)n - 1LL; i >= 0LL; i--) #define rep(i, n) FOR(i, 0, n) #define ALL(x) ((x).begin(), (x).end()) using namespace std; using ll = long long; template <typename T> using V = vector<T>; constexpr int Mod = 99...
[["+", 31, 16, 31, 2, 3, 4, 0, 16, 17, 33], ["+", 31, 16, 31, 2, 3, 4, 0, 16, 12, 13]]
1
305
//#pragma GCC target("avx2") //#pragma GCC optimize("O3") //# include <x86intrin.h> #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; // template<typename T> using ordered_set = tree <T, null_type, less<T>...
//#pragma GCC target("avx2") //#pragma GCC optimize("O3") //# include <x86intrin.h> #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; // template<typename T> using ordered_set = tree <T, null_type, less<T>...
[["-", 31, 16, 12, 2, 3, 4, 0, 16, 31, 22], ["-", 31, 16, 12, 2, 3, 4, 0, 16, 17, 33], ["+", 31, 16, 12, 2, 3, 4, 0, 16, 17, 33], ["+", 31, 16, 12, 2, 3, 4, 0, 16, 12, 22]]
1
405
#include <bits/stdc++.h> #define int long long #define ci(m) for (int i = 0; i < m; i++) #define cj(m) for (int j = 0; j < m; j++) #define ck(m) for (int k = 0; k < m; k++) #define gcd __gcd #define endl "\n" #define pb emplace_back #define setbits(x) __builtin_popcountll(x) #define zrobits(x) __builtin_ctzll(x) #defi...
#include <bits/stdc++.h> #define int long long #define ci(m) for (int i = 0; i < m; i++) #define cj(m) for (int j = 0; j < m; j++) #define ck(m) for (int k = 0; k < m; k++) #define gcd __gcd #define endl "\n" #define pb emplace_back #define setbits(x) __builtin_popcountll(x) #define zrobits(x) __builtin_ctzll(x) #defi...
[["-", 0, 2, 3, 4, 0, 16, 31, 16, 12, 22], ["+", 0, 2, 3, 4, 0, 16, 31, 16, 12, 22]]
1
558
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 MOD = 1000000007 def main(): X, Y, A, B, C, *PQR = map(int, read().split()) P = PQR[:A] Q = PQR[A : A + B] R = PQR[A + B :] P.sort(reverse=True) Q.sort(...
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 MOD = 1000000007 def main(): X, Y, A, B, C, *PQR = map(int, read().split()) P = PQR[:A] Q = PQR[A : A + B] R = PQR[A + B :] P.sort(reverse=True) Q.sort(...
[["-", 0, 1, 0, 662, 12, 657, 12, 206, 0, 70], ["-", 0, 662, 12, 657, 12, 206, 206, 663, 0, 102], ["-", 12, 657, 12, 206, 206, 663, 0, 657, 31, 22], ["-", 12, 657, 12, 206, 206, 663, 0, 657, 17, 72], ["-", 12, 657, 12, 206, 206, 663, 0, 657, 12, 22], ["-", 0, 1, 0, 662, 12, 657, 12, 206, 0, 73]]
5
167
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; int main() { int x, y, a, b, c; cin >> x >> y >> a >> b >> c; vector<ll> p(a), q(b), r(c); rep(i, a) cin >> p[i]; rep(i, b) cin >> q[i]; rep(i, c) cin >> r[i]; sor...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; int main() { int x, y, a, b, c; cin >> x >> y >> a >> b >> c; vector<ll> p(a), q(b), r(c); rep(i, a) cin >> p[i]; rep(i, b) cin >> q[i]; rep(i, c) cin >> r[i]; sor...
[["-", 0, 2, 3, 4, 0, 2, 63, 118, 119, 120], ["+", 0, 2, 3, 4, 0, 2, 63, 118, 119, 120]]
1
246
X,Y,A,B,C=map(int,input().split()) P=sorted(map(int,input().split()), reverse=True)[:X] Q=sorted(map(int,input().split()), reverse=True)[:Y] R=sorted(map(int,input().split()), reverse=True)[:X+Y] i,j=X-1,Y-1 for r in R: if i==-1 and j==-1: break elif j==-1: if r>P[i]: p[i]=r ...
X,Y,A,B,C=map(int,input().split()) P=sorted(map(int,input().split()), reverse=True)[:X] Q=sorted(map(int,input().split()), reverse=True)[:Y] R=sorted(map(int,input().split()), reverse=True)[:X+Y] i,j=X-1,Y-1 for r in R: if i==-1 and j==-1: break elif j==-1: if r>P[i]: P[i]=r ...
[["-", 64, 196, 0, 1, 0, 662, 31, 206, 51, 22], ["+", 64, 196, 0, 1, 0, 662, 31, 206, 51, 22]]
5
244
x,y,a,b,c,=map(int,input().split()) p=list(map(int,input().split())) q=list(map(int,input().split())) r=list(map(int,input().split())) p.sort(reverse=True) q.sort(reverse=True) r.sort(reverse=True) p=p[:x] q=q[:y] ans=p+q ans.sort(reverse=True) ans=[0]+ans nowi=x+y r=[0]+r nowr=0 while nowr<=c+1 and nowi>0 and r[nowr+1...
x,y,a,b,c,=map(int,input().split()) p=list(map(int,input().split())) q=list(map(int,input().split())) r=list(map(int,input().split())) p.sort(reverse=True) q.sort(reverse=True) r.sort(reverse=True) p=p[:x] q=q[:y] ans=p+q ans.sort(reverse=True) ans=[0]+ans nowi=x+y r=[0]+r nowr=0 while nowr<=c-1 and nowi>0 and r[nowr+1...
[["-", 15, 679, 31, 679, 31, 666, 0, 657, 17, 72], ["+", 15, 679, 31, 679, 31, 666, 0, 657, 17, 33]]
5
216
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #define REP(i, n) for (int i = 0; i < (n); i++) #define EPS (1e-7) #define INF (2e9) // cout << setprecision(10) using n...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #define REP(i, n) for (int i = 0; i < (n); i++) #define EPS (1e-7) #define INF (2e9) // cout << setprecision(10) using n...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 49, 22], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 49, 22], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 0, 21], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 0, 35], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78]]
1
295
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> P; typedef pair<ll, ll> PL; #define int ll const ll MOD = 1000000007; const ll INF_LL = (ll)1000000007 * 1000000007; const int INF_INT = (int)1000000007; const double PI = 3.14159265358979323846; const int dx[4] = {1, 0, -1, 0...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> P; typedef pair<ll, ll> PL; #define int ll const ll MOD = 1000000007; const ll INF_LL = (ll)1000000007 * 1000000007; const int INF_INT = (int)1000000007; const double PI = 3.14159265358979323846; const int dx[4] = {1, 0, -1, 0...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 47], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 20], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 47], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 20], ["-", 64, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["-", 75, 76, 0, 57, 15, 339, 51, 16, 1...
1
728
x, y, a, b, c = map(int, input().split()) p =list(map(int, input().split())) q = list(map(int, input().split())) r = list(map(int, input().split())) p = sorted(p) p = sorted(p) p = p[(len(p)-x):] q = q[(len(q)-y):] r=r+p r=r+q r = sorted(r) print(sum(r[(len(r)-x-y):]))
x, y, a, b, c = map(int, input().split()) p =list(map(int, input().split())) q = list(map(int, input().split())) r = list(map(int, input().split())) p = sorted(p) q = sorted(q) p = p[(len(p)-x):] q = q[(len(q)-y):] r = r + p r = r + q r = sorted(r) print(sum(r[(len(r)-x-y):]))
[["-", 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, 652, 3, 4, 0, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22]]
5
149
# -*- coding: utf-8 -*- ############# # Libraries # ############# import sys input = sys.stdin.readline import math #from math import gcd import bisect from collections import defaultdict from collections import deque from functools import lru_cache ############# # Constants # ############# MOD = 10**9+7 INF = fl...
# -*- coding: utf-8 -*- ############# # Libraries # ############# import sys input = sys.stdin.readline import math #from math import gcd import bisect from collections import defaultdict from collections import deque from functools import lru_cache ############# # Constants # ############# MOD = 10**9+7 INF = fl...
[["+", 0, 1, 0, 652, 3, 4, 0, 653, 141, 22], ["+", 0, 1, 0, 652, 3, 4, 0, 653, 0, 32], ["+", 0, 1, 0, 652, 3, 4, 0, 653, 51, 146]]
5
907
#include <bits/stdc++.h> using namespace std; #define pan(i, n) for (int i = 0; i < n; i++) #define pans(i, n, a) for (int i = a; i < n; i++) #define ll long long int #define vi vector<int> #define vl vector<ll> #define pb push_back #define INF INT_MAX #define PI 3.141592653 #define inf 1000007 #define pll pair<ll, l...
#include <bits/stdc++.h> using namespace std; #define pan(i, n) for (int i = 0; i < n; i++) #define pans(i, n, a) for (int i = a; i < n; i++) #define ll long long int #define vi vector<int> #define vl vector<ll> #define pb push_back #define INF INT_MAX #define PI 3.141592653 #define inf 1000007 #define pll pair<ll, l...
[["-", 8, 9, 0, 43, 49, 50, 51, 41, 64, 22], ["-", 8, 9, 0, 43, 49, 50, 51, 41, 0, 102], ["+", 8, 9, 0, 43, 49, 50, 51, 41, 0, 102], ["+", 8, 9, 0, 43, 49, 50, 51, 41, 75, 22]]
1
393
from sys import stdin def main(): x, y, a, b, c = map(int, stdin.readline().split()) p = list(map(int, stdin.readline().split())) q = list(map(int, stdin.readline().split())) r = list(map(int, stdin.readline().split())) pqr = [] for pi in p: pqr.append([pi, 0]) for qi in q: ...
from sys import stdin def main(): x, y, a, b, c = map(int, stdin.readline().split()) p = list(map(int, stdin.readline().split())) q = list(map(int, stdin.readline().split())) r = list(map(int, stdin.readline().split())) pqr = [] for pi in p: pqr.append([pi, 0]) for qi in q: ...
[["-", 0, 7, 8, 196, 0, 57, 75, 665, 0, 683], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121]]
5
271
#include <algorithm> #include <cmath> #include <cstdio> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <utility> #include <vector> using namespace std; typedef long long ll; const ll mod = 1000000007; #define rep(i, n) for (int i =...
#include <algorithm> #include <cmath> #include <cstdio> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <utility> #include <vector> using namespace std; typedef long long ll; const ll mod = 1000000007; #define rep(i, n) for (int i =...
[["-", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78]]
1
349
x, y, a, b, c = map(int, input().split()) red = list(map(int, input().split())) green = list(map(int, input().split())) colorless = list(map(int, input().split())) red.sort(reverse = True) green.sort(reverse = True) colorless.sort(reverse = True) ret = red[:x] + green[:y] ret.sort() for i in range(len(colorless)): ...
x, y, a, b, c = map(int, input().split()) red = list(map(int, input().split())) green = list(map(int, input().split())) colorless = list(map(int, input().split())) red.sort(reverse = True) green.sort(reverse = True) colorless.sort(reverse = True) ret = red[:x] + green[:y] ret.sort() for i in range(len(colorless)): ...
[["+", 0, 7, 8, 196, 0, 57, 75, 76, 0, 95], ["+", 0, 7, 8, 196, 0, 57, 75, 76, 0, 102], ["+", 0, 57, 75, 76, 8, 196, 0, 93, 0, 94]]
5
153
x, y, a, b, c = map(int, input().split()) p = list(map(int, input().split())) q = list(map(int, input().split())) r = list(map(int, input().split())) p.sort(reverse=True) q.sort(reverse=True) r.sort(reverse=True) ans = p[:x] + q[:y] + r print(sum(ans.sort(reverse=True)[:x + y]))
x, y, a, b, c = map(int, input().split()) p = list(map(int, input().split())) q = list(map(int, input().split())) r = list(map(int, input().split())) p.sort(reverse=True) q.sort(reverse=True) r.sort(reverse=True) ans = p[:x] + q[:y] + r print(sum(sorted(ans, reverse=True)[:x + y]))
[["-", 3, 4, 0, 206, 51, 652, 63, 319, 500, 22], ["-", 3, 4, 0, 206, 51, 652, 63, 319, 0, 131], ["-", 3, 4, 0, 206, 51, 652, 63, 319, 319, 22], ["+", 0, 652, 3, 4, 0, 206, 51, 652, 63, 22], ["+", 3, 4, 0, 206, 51, 652, 3, 4, 0, 22], ["+", 3, 4, 0, 206, 51, 652, 3, 4, 0, 21]]
5
132
X, Y, A, B, C = map(int, input().split()) P = sorted([int(i) for i in input().split()], reverse=True) Q = sorted([int(i) for i in input().split()], reverse=True) R = sorted([int(i) for i in input().split()]) S = sorted(P[:X]+Q[:Y]+R, reverse=True) ans = sum(S[:X+Y])
X, Y, A, B, C = map(int, input().split()) P = sorted([int(i) for i in input().split()], reverse=True) Q = sorted([int(i) for i in input().split()], reverse=True) R = sorted([int(i) for i in input().split()]) S = sorted(P[:X]+Q[:Y]+R, reverse=True) print(sum(S[:X+Y]))
[["-", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["-", 36, 36, 0, 656, 0, 1, 0, 662, 0, 32], ["+", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
127
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<vi> vvi; typedef vector<vl> vvl; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<pii> vii; typedef vector<pll> vll; typedef map<int, int> mii; typedef vector<char> ...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<vi> vvi; typedef vector<vl> vvl; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<pii> vii; typedef vector<pll> vll; typedef map<int, int> mii; typedef vector<char> ...
[["-", 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]]
1
854
#include <bits/stdc++.h> #define int long long using namespace std; const int N = 1e5 + 5; int a[N]; int b[N]; int c[N]; int n, m, q, x, y; signed main() { // freopen("file.inp","r",stdin); cin >> x >> y >> n >> m >> q; for (int i = 1; i <= n; i++) { cin >> a[i]; } sort(a + 1, a + n + 1, greater<int>())...
#include <bits/stdc++.h> #define int long long using namespace std; const int N = 1e5 + 5; int a[N]; int b[N]; int c[N]; int n, m, q, x, y; signed main() { // freopen("file.inp","r",stdin); cin >> x >> y >> n >> m >> q; for (int i = 1; i <= n; i++) { cin >> a[i]; } sort(a + 1, a + n + 1, greater<int>())...
[["-", 0, 2, 3, 4, 0, 16, 31, 16, 12, 22], ["+", 0, 2, 3, 4, 0, 16, 31, 16, 12, 22]]
1
324
x,y,a,b,c=map(int,input().split()) p=sorted(list(map(int,input().split())),reverse=True) q=sorted(list(map(int,input().split())),reverse=True) r=sorted(list(map(int,input().split())),reverse=True) p2=p[:x] q2=q[:y] memop=x-1 memoq=y-1 sp=sum(p2) sq=sum(q2) k=0 flagp=0 flagq=0 while k<c: if memop<0: flagp=1 ...
x,y,a,b,c=map(int,input().split()) p=sorted(list(map(int,input().split())),reverse=True) q=sorted(list(map(int,input().split())),reverse=True) r=sorted(list(map(int,input().split())),reverse=True) p2=p[:x] q2=q[:y] memop=x-1 memoq=y-1 sp=sum(p2) sq=sum(q2) k=0 flagp=0 flagq=0 while k<c: if memop<0: flagp=1 ...
[["+", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 31, 22], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 22], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]]
5
360
#include "bits/stdc++.h" using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) typedef long long INT; double PI = 3.14159265; const long long INF = 1LL << 60; //---// int main() { int x, y, a, b, c, p[100010] = {}, q[100010] = {}, r; vector<int> in; INT sum = 0; cin >> x >> y >> a >> b >> c; r...
#include "bits/stdc++.h" using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) typedef long long INT; double PI = 3.14159265; const long long INF = 1LL << 60; //---// int main() { int x, y, a, b, c, p[100010] = {}, q[100010] = {}, r; vector<int> in; INT sum = 0; cin >> x >> y >> a >> b >> c; r...
[["-", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 21], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["-", 0, 1, 0, 2, 3, 4, 0, 25, 0, 35]]
1
253
#define _CRT_SECURE_NO_WARNINGS #define _USE_MATH_DEFINES #include <bits/stdc++.h> #include <unordered_map> using namespace std; #define Ma7moud_7amdy \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); ...
#define _CRT_SECURE_NO_WARNINGS #define _USE_MATH_DEFINES #include <bits/stdc++.h> #include <unordered_map> using namespace std; #define Ma7moud_7amdy \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); ...
[["-", 12, 16, 12, 16, 31, 16, 12, 69, 28, 22], ["+", 12, 16, 12, 16, 31, 16, 12, 69, 28, 22]]
1
690
#include <algorithm> #include <iostream> using namespace std; const int N = 3e6 + 1e5; long long pt[N], dd[N], mark[N], x, y, a, b, c, st1, st2, st3, ans = 0; bool cmp(int i, int j) { return pt[i] >= pt[j]; } int main() { cin >> x >> y >> a >> b >> c; for (int i = 1; i <= a + b + c; i++) { cin >> pt[i]; dd[...
#include <algorithm> #include <iostream> using namespace std; const int N = 1e6 + 1e5; long long pt[N], dd[N], mark[N], x, y, a, b, c, st1, st2, st3, ans = 0; bool cmp(int i, int j) { return pt[i] > pt[j]; } int main() { cin >> x >> y >> a >> b >> c; for (int i = 1; i <= a + b + c; i++) { cin >> pt[i]; dd[i...
[["-", 0, 30, 0, 43, 49, 50, 51, 16, 31, 13], ["+", 0, 30, 0, 43, 49, 50, 51, 16, 31, 13], ["-", 0, 14, 8, 9, 0, 37, 0, 16, 17, 20], ["+", 0, 14, 8, 9, 0, 37, 0, 16, 17, 47], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22], ["+", 0, 57, 1...
1
328
x,y,a,b,c = map(int, input().split()) p = list(map(int, input().split())) q = list(map(int, input().split())) r = list(map(int, input().split())) p = sorted(p, reverse=True) q = sorted(q, reverse=True) pq = sorted(p[:x] + q[:y]) r = sorted(r) ans=0 j = r.pop() for i in pq: if i < j: ans+=j j = 0 if r: ...
x,y,a,b,c = map(int, input().split()) p = list(map(int, input().split())) q = list(map(int, input().split())) r = list(map(int, input().split())) p = sorted(p, reverse=True) q = sorted(q, reverse=True) pq = sorted(p[:x] + q[:y]) r = sorted(r) ans=0 j = r.pop() for i in pq: if i < j: ans += j j = 0 if r:...
[["-", 0, 57, 75, 76, 8, 196, 0, 93, 0, 94], ["-", 0, 7, 8, 196, 0, 57, 75, 76, 0, 95], ["-", 0, 7, 8, 196, 0, 57, 75, 76, 0, 102]]
5
163
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int x, y, a, b, c; cin >> x >> y >> a >> b >> c; vector<int> p(a); for (int i = 0; i < a; i++) cin >> p[i]; vector<int> q(b); for (int i = 0; i < b; i++) cin >> q[i]; vector<int> r(c); for (int i = 0; i < c; i++) ...
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int x, y, a, b, c; cin >> x >> y >> a >> b >> c; vector<int> p(a); for (int i = 0; i < a; i++) cin >> p[i]; vector<int> q(b); for (int i = 0; i < b; i++) cin >> q[i]; vector<int> r(c); for (int i = 0; i < c; i++) ...
[["-", 8, 9, 0, 52, 15, 339, 51, 16, 17, 106], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 17, 98]]
1
338
X, Y, A, B, C = map(int, input().split()) p = sorted(list(map(int, input().split())), reverse=True) q = sorted(list(map(int, input().split())), reverse=True) r = sorted(list(map(int, input().split())), reverse=True) red = p[:X] green = q[:Y] red_no_eat = 0 green_no_eat = 0 for no in r: red_worst = red[-red_no_eat...
X, Y, A, B, C = map(int, input().split()) p = sorted(list(map(int, input().split())), reverse=True) q = sorted(list(map(int, input().split())), reverse=True) r = sorted(list(map(int, input().split())), reverse=True) red = p[:X] green = q[:Y] red_no_eat = 0 green_no_eat = 0 for no in r: red_worst = red[-red_no_eat...
[["-", 0, 1, 0, 662, 12, 41, 0, 666, 667, 19], ["+", 0, 1, 0, 662, 12, 41, 0, 666, 667, 18]]
5
210
X, Y, A, B, C = map(int, input().split()) p = list(map(int, input().split())) q = list(map(int, input().split())) r = list(map(int, input().split())) p.sort(reverse=True) q.sort(reverse=True) r.sort(reverse=True) sa = sum(p[:X]) sb = sum(q[:Y]) p.append(float('inf')) q.append(float('inf')) ans = sa + sb nr = 0 np ...
X, Y, A, B, C = map(int, input().split()) p = list(map(int, input().split())) q = list(map(int, input().split())) r = list(map(int, input().split())) p.sort(reverse=True) q.sort(reverse=True) r.sort(reverse=True) sa = sum(p[:X]) sb = sum(q[:Y]) p.append(float('inf')) q.append(float('inf')) ans = sa + sb nr = 0 np ...
[["-", 0, 57, 75, 665, 15, 666, 0, 206, 51, 22], ["-", 0, 57, 75, 665, 15, 666, 0, 206, 0, 70], ["-", 0, 57, 75, 665, 15, 666, 0, 206, 206, 22], ["-", 0, 57, 75, 665, 15, 666, 0, 206, 0, 73], ["-", 8, 196, 0, 57, 75, 665, 15, 666, 667, 47]]
5
243
import sys input = sys.stdin.readline x, y, a, b, c = map(int, input().split()) p = sorted(list(map(int, input().split()))) q = sorted(list(map(int, input().split()))) r = sorted(list(map(int, input().split()))) n = 0 np = 0 nq = 0 ans = 0 while n < x + y: cs = [] if p and np < x: cs.append(p[-1]) ...
import sys input = sys.stdin.readline x, y, a, b, c = map(int, input().split()) p = sorted(list(map(int, input().split()))) q = sorted(list(map(int, input().split()))) r = sorted(list(map(int, input().split()))) n = 0 np = 0 nq = 0 ans = 0 while n < x + y: cs = [] if p and np < x: cs.append(p[-1]) ...
[["+", 0, 52, 8, 196, 0, 57, 15, 679, 31, 22], ["+", 0, 52, 8, 196, 0, 57, 15, 679, 17, 355], ["+", 8, 196, 0, 57, 75, 665, 15, 679, 31, 22], ["+", 8, 196, 0, 57, 75, 665, 15, 679, 17, 355]]
5
221
#import sys #import numpy as np import math #from fractions import Fraction import itertools from collections import deque from collections import Counter #import heapq #from fractions import gcd #input=sys.stdin.readline import bisect x,y,a,b,c=map(int,input().split()) p=list(map(int,input().split())) q=list(map(int,...
#import sys #import numpy as np import math #from fractions import Fraction import itertools from collections import deque from collections import Counter #import heapq #from fractions import gcd #input=sys.stdin.readline import bisect x,y,a,b,c=map(int,input().split()) p=list(map(int,input().split())) q=list(map(int,...
[["-", 15, 679, 12, 23, 0, 679, 12, 666, 667, 18], ["+", 15, 679, 12, 23, 0, 679, 12, 666, 667, 19]]
5
296
class Problem attr_accessor :a, :b, :n, :m, :h, :w, :ans, :c ,:x, :y def initialize @x,@y,@a,@b,@c = gets.to_s.split.map{ |v| v.to_i } @p = gets.to_s.split.map{ |v| v.to_i }.sort!.reverse!.take(a) @q = gets.to_s.split.map{ |v| v.to_i }.sort!.reverse!.take(b) @r = gets.to_s.split.map{ |v| v.to_i } ...
class Problem attr_accessor :a, :b, :n, :m, :h, :w, :ans, :c ,:x, :y def initialize @x,@y,@a,@b,@c = gets.to_s.split.map{ |v| v.to_i } @p = gets.to_s.split.map{ |v| v.to_i }.sort!.reverse!.take(x) @q = gets.to_s.split.map{ |v| v.to_i }.sort!.reverse!.take(y) @r = gets.to_s.split.map{ |v| v.to_i } ...
[["-", 8, 736, 0, 662, 12, 652, 3, 4, 0, 22], ["+", 8, 736, 0, 662, 12, 652, 3, 4, 0, 22]]
4
156
def red_and_green_apples(X, Y, A, B, C, P, Q, R): P.sort(reverse=True) Q.sort(reverse=True) R.sort(reverse=True) P = P[:X] Q = Q[:Y] q = P + Q + R q.sort(reverse=True) return sum(q[:X + Y]) X, Y, A, B, C = map(int, input().split()) P = list(map(int, input().split())) Q = list(map(int...
def red_and_green_apples(X, Y, A, B, C, P, Q, R): P.sort(reverse=True) Q.sort(reverse=True) R.sort(reverse=True) P = P[:X] Q = Q[:Y] q = P + Q + R q.sort(reverse=True) return sum(q[:X + Y]) X, Y, A, B, C = map(int, input().split()) P = list(map(int, input().split())) Q = list(map(int...
[["+", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
188
x, y, a, b, c = gets.split.map(&:to_i) p = gets.split.map(&:to_i) q = gets.split.map(&:to_i) r = gets.split.map(&:to_i) puts (p[-x, x] + q[-y, y] + r).sort[-(x + y), x + y].reduce(0) {|i, j| i + j}
x, y, a, b, c = gets.split.map(&:to_i) p = gets.split.map(&:to_i) q = gets.split.map(&:to_i) r = gets.split.map(&:to_i) puts (p.sort[-x, x] + q.sort[-y, y] + r).sort[-(x + y), x + y].reduce(0) {|i, j| i + j}
[["+", 0, 738, 31, 738, 31, 742, 500, 652, 17, 131], ["+", 0, 738, 31, 738, 31, 742, 500, 652, 735, 22], ["+", 0, 738, 31, 738, 12, 742, 500, 652, 17, 131], ["+", 0, 738, 31, 738, 12, 742, 500, 652, 735, 22]]
4
101
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define repr(i, a, b) for (int i = a; i < b; i++) #define all(x) (x).begin(), (x).end() // 昇順ソート #define rall(v) (v).rbegin(), (v).rend() // 降順ソート #define FastIO ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0) ty...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define repr(i, a, b) for (int i = a; i < b; i++) #define all(x) (x).begin(), (x).end() // 昇順ソート #define rall(v) (v).rbegin(), (v).rend() // 降順ソート #define FastIO ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0) ty...
[["+", 0, 52, 8, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 27, 17, 29], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
1
541
/* Sviatoslav Bidzilia 2020 CF: anakib1 */ #include <algorithm> #include <bitset> #include <cassert> #include <chrono> #include <cmath> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map...
/* Sviatoslav Bidzilia 2020 CF: anakib1 */ #include <algorithm> #include <bitset> #include <cassert> #include <chrono> #include <cmath> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map...
[["-", 0, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["-", 0, 1, 0, 16, 31, 16, 31, 16, 17, 152], ["+", 0, 1, 0, 16, 31, 16, 31, 16, 17, 152], ["+", 0, 1, 0, 16, 31, 16, 31, 16, 12, 22]]
1
793
#include <bits/stdc++.h> #define pb push_back using namespace std; inline int read() { int sum = 0, ff = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == '-') ff = -1; ch = getchar(); } while (isdigit(ch)) sum = sum * 10 + (ch ^ 48), ch = getchar(); return sum * ff; } int n, x, y...
#include <bits/stdc++.h> #define pb push_back using namespace std; inline int read() { int sum = 0, ff = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == '-') ff = -1; ch = getchar(); } while (isdigit(ch)) sum = sum * 10 + (ch ^ 48), ch = getchar(); return sum * ff; } int n, x, y...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18]]
1
220
#pragma GCC optimize("O3") #pragma GCC target("sse4") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; typedef long long ll; typedef vector<int> vi; typedef pair<int, int> pii; template <class T> using ordered_set ...
#pragma GCC optimize("O3") #pragma GCC target("sse4") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; typedef long long ll; typedef vector<int> vi; typedef pair<int, int> pii; template <class T> using ordered_set ...
[["+", 12, 2, 3, 4, 0, 16, 31, 16, 17, 72], ["+", 12, 2, 3, 4, 0, 16, 31, 16, 12, 22], ["+", 0, 11, 12, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 11, 12, 2, 3, 4, 0, 16, 12, 22]]
1
528
#include <bits/stdc++.h> using namespace std; int N, x, y, ans[2010]; int main() { cin >> N >> x >> y; for (int i = 1; i <= x; i++) for (int j = i + 1; j <= x; j++) ans[j - i]++; for (int i = y; i <= N; i++) for (int j = y + 1; j <= N; j++) ans[j - i]++; for (int i = x + 1; i < y; i++) ...
#include <bits/stdc++.h> using namespace std; int N, x, y, ans[2010]; int main() { cin >> N >> x >> y; for (int i = 1; i <= x; i++) for (int j = i + 1; j <= x; j++) ans[j - i]++; for (int i = y; i <= N; i++) for (int j = i + 1; j <= N; j++) ans[j - i]++; for (int i = x + 1; i < y; i++) ...
[["-", 8, 7, 10, 43, 49, 50, 51, 16, 31, 22], ["+", 8, 7, 10, 43, 49, 50, 51, 16, 31, 22]]
1
331
#include <bits/stdc++.h> using namespace std; namespace fastIO { #define BUF_SIZE 100000 #define OUT_SIZE 100000 // fread->read bool IOerror = 0; // inline char nc(){char ch=getchar();if(ch==-1)IOerror=1;return ch;} inline char nc() { static char buf[BUF_SIZE], *p1 = buf + BUF_SIZE, *pend = buf + BUF_SIZE; if (p1 =...
#include <bits/stdc++.h> using namespace std; namespace fastIO { #define BUF_SIZE 100000 #define OUT_SIZE 100000 // fread->read bool IOerror = 0; // inline char nc(){char ch=getchar();if(ch==-1)IOerror=1;return ch;} inline char nc() { static char buf[BUF_SIZE], *p1 = buf + BUF_SIZE, *pend = buf + BUF_SIZE; if (p1 =...
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 18]]
1
1,852