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
conf = 0 num_char = int(input()) char = list(map(int, input().split())) char.sort(reverse=True) count = 0 conf_int = 0 for i in range(num_char): if count == 0: count = 1 elif count == 1: count = 2 conf = char[conf_int] count_int = 0 conf_int = 1 else: if count_int == 0 : conf += char...
conf = 0 num_char = int(input()) char = list(map(int, input().split())) char.sort(reverse=True) count = 0 conf_int = 0 for i in range(num_char): if count == 0: count = 1 elif count == 1: count = 2 conf = char[conf_int] count_int = 0 conf_int = 1 else: if count_int == 0 : conf += char...
[["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22]]
5
112
n = int(input()) a = list(map(int, input().split())) a.sort(reverse=True) ans = a[-1] for i in range(0, n-2): ans += a[i // 2] #print(ans) print(ans)
n = int(input()) a = list(map(int, input().split())) a.sort(reverse=True) ans = a[0] for i in range(2, n): ans += a[i // 2] #print(ans) print(ans)
[["-", 0, 1, 0, 662, 12, 206, 206, 664, 17, 33], ["-", 0, 1, 0, 662, 12, 206, 206, 664, 28, 612], ["+", 0, 656, 0, 1, 0, 662, 12, 206, 206, 612], ["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 17, 33], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612...
5
65
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main(void) { int n; cin >> n; vector<ll> v(n); rep(i, n) { cin >> v[i]; } sort(v.begin(), v.end(), greater<ll>()); int now = 0; ll ans = 0; rep(i, n - 1) { ans += v[now]; if (...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main(void) { int n; cin >> n; vector<ll> v(n); rep(i, n) { cin >> v[i]; } sort(v.begin(), v.end(), greater<ll>()); int now = 0; ll ans = 0; rep(i, n - 1) { ans += v[now]; if (...
[["-", 0, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 0, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22]]
1
137
import sys input = sys.stdin.readline #n = int(input()) #l = list(map(int, input().split())) ''' a=[] b=[] for i in range(): A, B = map(int, input().split()) a.append(A) b.append(B)''' n=int(input()) a=list(map(int,input().split())) a.sort() #print(a) ans=0 from math import floor for i in range(1,n-1...
import sys input = sys.stdin.readline #n = int(input()) #l = list(map(int, input().split())) ''' a=[] b=[] for i in range(): A, B = map(int, input().split()) a.append(A) b.append(B)''' n=int(input()) a=list(map(int,input().split())) a.sort() #print(a) ans=0 from math import floor for i in range(1,n):...
[["-", 0, 7, 12, 652, 3, 4, 0, 657, 17, 33], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
84
n = int(input()) a = list(map(int, input().split())) a.sort() ans = 0 for i in range(1,n+1): ans += a[n-i//2-1] print(ans)
n = int(input()) a = list(map(int, input().split())) a.sort() ans = 0 for i in range(1, n): ans += a[n - i//2 - 1] print(ans)
[["-", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
61
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> #include <queue> using namespace std; int n; long long ans = 0; long long a[200002]; bool b = false; int main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; } sort(a + 1, a + 1 + n); ans += a[n]; int tot = (n - 2)...
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> #include <queue> using namespace std; int n; long long ans = 0; long long a[200002]; bool b = false; int main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; } sort(a + 1, a + 1 + n); ans += a[n]; int tot = (n - 2)...
[["-", 12, 69, 341, 342, 0, 16, 31, 16, 31, 22], ["-", 12, 69, 341, 342, 0, 16, 31, 16, 17, 33], ["-", 0, 11, 12, 69, 341, 342, 0, 16, 17, 33], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 17, 72]]
1
180
N = int(input()) a = list(map(int, input().split())) a.sort(reverse=True) arrival = 1 ans = 0 while arrival < N: score = a.popleft() if arrival == 1: ans += score arrival += 1 else: ans += score*min(2, N - arrival) arrival += 2 print(ans)
N = int(input()) a = list(map(int, input().split())) a.sort() arrival = 1 ans = 0 while arrival < N: score = a.pop() if arrival == 1: ans += score arrival += 1 else: ans += score*min(2, N - arrival) arrival += 2 print(ans)
[["-", 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], ["-", 0, 1, 0, 662, 12, 652, 63, 319, 319, 22], ["+", 0, 1, 0, 662, 12, 652, 63, 319, 319, 22]]
5
83
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a.begin(), a.end()); long ans = a[n - 1]; int cnt = 2; for (int i = 2; i < n; i++) { ans += a[n - cnt]; // cout << a[n-cnt] << endl; if (i ...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a.begin(), a.end()); long ans = a[n - 1]; int cnt = 2; for (int i = 2; i < n; i++) { ans += a[n - cnt]; // cout << a[n-cnt] << endl; if (i ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
127
import math import sys import os from operator import mul sys.setrecursionlimit(10**7) def _S(): return sys.stdin.readline().rstrip() def I(): return int(_S()) def LS(): return list(_S().split()) def LI(): return list(map(int,LS())) if os.getenv("LOCAL"): inputFile = basename_without_ext = os.path.splitext(os.pa...
import math import sys import os from operator import mul sys.setrecursionlimit(10**7) def _S(): return sys.stdin.readline().rstrip() def I(): return int(_S()) def LS(): return list(_S().split()) def LI(): return list(map(int,LS())) if os.getenv("LOCAL"): inputFile = basename_without_ext = os.path.splitext(os.pa...
[["-", 75, 76, 8, 196, 0, 1, 0, 677, 17, 110], ["+", 75, 76, 8, 196, 0, 1, 0, 677, 17, 107]]
5
234
//#include <tourist> #include <bits/stdc++.h> using namespace std; typedef long long ll; const int INF = 1e9; const ll LINF = ll(1e18); const int MOD = 1000000007; const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0}; const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1}; #defin...
//#include <tourist> #include <bits/stdc++.h> using namespace std; typedef long long ll; const int INF = 1e9; const ll LINF = ll(1e18); const int MOD = 1000000007; const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0}; const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1}; #defin...
[["-", 64, 9, 0, 1, 0, 11, 12, 91, 17, 92], ["-", 64, 9, 0, 1, 0, 11, 12, 91, 28, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 146], ["-", 0, 9, 0, 1, 0, 11, 12, 91, 17, 92], ["-", 0, 9, 0, 1, 0, 11, 12, 91, 28, 22], ["+", 75, 76, 0, 9, 0, 1, 0, 11, 12, 147]]
1
410
#include <bits/stdc++.h> using namespace std; int main() { int64_t n, sum = 0; cin >> n; int a[n]; for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); reverse(a, a + n); for (int i = 0; i < n - 1; i++) sum += a[i]; cout << sum << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int64_t n, sum = 0; cin >> n; int a[n]; for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); reverse(a, a + n); for (int i = 1; i < n; i++) sum += a[i / 2]; cout << sum << endl; }
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 17, 85], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 12, 13]]
1
97
n = int(input()) f = list(map(int,input().split())) f.sort(reverse = True) ans = 0 if n%2 == 0: for i in range(n//2): ans += f[i] * 2 ans -= f[0] else: for i in range(n//2): ans += f[i] * 2 ans += f[n//2+1]-f[0] print(ans)
n = int(input()) f = list(map(int,input().split())) f.sort(reverse = True) ans = 0 if n%2 == 0: for i in range(n//2): ans += f[i] * 2 ans -= f[0] else: for i in range(n//2): ans += f[i] * 2 ans += f[n//2]-f[0] print(ans)
[["-", 0, 677, 12, 657, 31, 206, 206, 657, 17, 72], ["-", 0, 677, 12, 657, 31, 206, 206, 657, 12, 612]]
5
106
/* URL https:// SCORE 0 AC false WA false TLE false MLE false TASK_TYPE FAILURE_TYPE NOTES */ #include <algorithm> #include <cstdint> #include <functional> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <numeric> #include <optional> #include <queue> #include <set> #include <stack> #inc...
/* URL https:// SCORE 0 AC false WA false TLE false MLE false TASK_TYPE FAILURE_TYPE NOTES */ #include <algorithm> #include <cstdint> #include <functional> #include <iomanip> #include <iostream> #include <limits> #include <map> #include <numeric> #include <optional> #include <queue> #include <set> #include <stack> #inc...
[["-", 0, 11, 12, 69, 341, 342, 0, 16, 17, 33], ["-", 0, 11, 12, 69, 341, 342, 0, 16, 12, 13], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 17, 85], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 12, 13]]
1
5,600
n = int(input()) a = list(map(int, input().split())) a.sort(reverse=True) cnt = n-2 ans = a[0] for i in a[1:]: if cnt==0: break elif cnt>2: cnt -= 2 ans += (i*2) else: cnt -=1 ans += i print(ans)
n = int(input()) a = list(map(int, input().split())) a.sort(reverse=True) cnt = n-2 ans = a[0] for i in a[1:]: if cnt==0: break elif cnt>=2: cnt -= 2 ans += (i*2) else: cnt -=1 ans += i print(ans)
[["-", 8, 196, 0, 57, 75, 665, 15, 666, 667, 47], ["+", 8, 196, 0, 57, 75, 665, 15, 666, 667, 20]]
5
86
#include <stdio.h> typedef struct { int key, id; } data; typedef struct { data obj[200001]; int size; } max_heap; void push(data x, max_heap *h) { int i = ++(h->size); data tmp; h->obj[i] = x; while (i > 1) { if (h->obj[i].key > h->obj[i >> 1].key) { tmp = h->obj[i >> 1]; h->obj[i >> 1]...
#include <stdio.h> typedef struct { int key, id; } data; typedef struct { data obj[200001]; int size; } max_heap; void push(data x, max_heap *h) { int i = ++(h->size); data tmp; h->obj[i] = x; while (i > 1) { if (h->obj[i].key > h->obj[i >> 1].key) { tmp = h->obj[i >> 1]; h->obj[i >> 1]...
[["-", 0, 57, 15, 23, 0, 16, 12, 16, 12, 13], ["+", 0, 57, 15, 23, 0, 16, 12, 16, 12, 13]]
0
455
n = int(input()) a = list(map(int,input().split())) b = sorted(a,reverse = True) ans = 0 for i in range(0,n): if i == 0: ans += 0 else: ans += b[n-(i//2)-1] print(ans)
n = int(input()) a = list(map(int,input().split())) b = sorted(a) ans = 0 for i in range(0,n): if i == 0: ans += 0 else: ans += b[n-(i//2)-1] print(ans)
[["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 21], ["-", 0, 662, 12, 652, 3, 4, 0, 653, 141, 22], ["-", 0, 662, 12, 652, 3, 4, 0, 653, 0, 32], ["-", 0, 662, 12, 652, 3, 4, 0, 653, 51, 146]]
5
76
#include <bits/stdc++.h> using namespace std; #define endl "\n" #define MOD 1000000007 typedef long long ll; typedef pair<int, int> pii; priority_queue<pii> q; bool cmp(int a, int b) { return a > b; } int n, a[200020]; ll res; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> n; for (int i = 1...
#include <bits/stdc++.h> using namespace std; #define endl "\n" #define MOD 1000000007 typedef long long ll; typedef pair<int, int> pii; priority_queue<pii> q; bool cmp(int a, int b) { return a > b; } int n, a[200020]; ll res; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> n; for (int i = 1...
[["+", 8, 9, 0, 1, 0, 2, 63, 118, 28, 22], ["+", 8, 9, 0, 1, 0, 2, 63, 118, 17, 131], ["+", 8, 9, 0, 1, 0, 2, 63, 118, 119, 120], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["+", 0, 9, 0, 7, 8, 9, 0, 1, 0, 35]]
1
282
#include <algorithm> #include <cmath> #include <cstdlib> #include <cstring> #include <iostream> #include <iterator> #include <list> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <string> #include <vector> using name...
#include <algorithm> #include <cmath> #include <cstdlib> #include <cstring> #include <iostream> #include <iterator> #include <list> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <string> #include <vector> using name...
[["-", 341, 342, 0, 16, 31, 23, 0, 16, 17, 72], ["+", 341, 342, 0, 16, 31, 23, 0, 16, 17, 33]]
1
251
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int INF = 1e9; int main() { int n; cin >> n; vector<ll> a(n); for (int i = 0; i < n; ++i) { cin >> a[i]; } sort(a.begin(), a.end()); ll res = a[n - 1]; for (int i = 0; i ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int INF = 1e9; int main() { int n; cin >> n; vector<ll> a(n); for (int i = 0; i < n; ++i) { cin >> a[i]; } sort(a.begin(), a.end()); ll res = a[n - 1]; for (int i = 0; i ...
[["-", 12, 69, 341, 342, 0, 16, 31, 16, 12, 13], ["+", 12, 69, 341, 342, 0, 16, 31, 16, 12, 13]]
1
169
#include <bits/stdc++.h> using ll = long long; using namespace std; #define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++) #define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++) #define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--) #define rreps(i, n) for (int i = ((int)(n)); i ...
#include <bits/stdc++.h> using ll = long long; using namespace std; #define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++) #define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++) #define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--) #define rreps(i, n) for (int i = ((int)(n)); i ...
[["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
1
359
N = int(input()) A = list(map(int,input().split())) A.sort(reverse=True) ans = 0 if N % 2 == 1: ans += A[0] ans += A[N//2 + 1] for i in range(1,N//2): ans += A[i]*2 else: ans += A[0] for i in range(1,N//2): ans += A[i]*2 print(ans)
N = int(input()) A = list(map(int,input().split())) A.sort(reverse=True) ans = 0 if N % 2 == 1: ans += A[0] ans += A[N//2] for i in range(1,N//2): ans += A[i]*2 else: ans += A[0] for i in range(1,N//2): ans += A[i]*2 print(ans)
[["-", 0, 1, 0, 677, 12, 206, 206, 657, 17, 72], ["-", 0, 1, 0, 677, 12, 206, 206, 657, 12, 612]]
5
111
/* Author: Anthony Ngene Created: 20/08/2020 - 22:18 */ import java.io.*; import java.util.*; public class Main { // If you follow the track of an elephant, you will never be entangled in the // bush. - African Proverb public static void main(String[] args) throws IOException { in = new FastScanner(...
/* Author: Anthony Ngene Created: 20/08/2020 - 22:18 */ import java.io.*; import java.util.*; public class Main { // If you follow the track of an elephant, you will never be entangled in the // bush. - African Proverb public static void main(String[] args) throws IOException { in = new FastScanner(...
[["+", 0, 57, 64, 196, 0, 1, 0, 27, 0, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 27, 0, 68], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35]]
3
1,692
import java.util.Arrays; import java.util.Collections; import java.util.Scanner; public class Main { public static void main(String[] args) { try (Scanner scan = new Scanner(System.in)) { int N = scan.nextInt(); Long[] A = new Long[N]; for (int i = 0; i < N; i++) A[i] = scan.nextLong()...
import java.util.Arrays; import java.util.Collections; import java.util.Scanner; public class Main { public static void main(String[] args) { try (Scanner scan = new Scanner(System.in)) { int N = scan.nextInt(); Long[] A = new Long[N]; for (int i = 0; i < N; i++) A[i] = scan.nextLong()...
[["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 499], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35]]
3
209
# -*- coding: utf-8 -*- import sys def main(): N = int( sys.stdin.readline() ) A_list = list(map(int, sys.stdin.readline().split())) A_list.sort(reverse=True) arrived_idx = 1 comfort = A_list[0] for i in range(2, len(A_list)): if ( len(A_list) - 1 - arrived_idx ) >= 2: co...
# -*- coding: utf-8 -*- import sys def main(): N = int( sys.stdin.readline() ) A_list = list(map(int, sys.stdin.readline().split())) A_list.sort(reverse=True) arrived_idx = 1 comfort = A_list[0] for i in range(1, len(A_list)): if ( len(A_list) - 1 - arrived_idx ) >= 2: co...
[["-", 8, 196, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 612]]
5
137
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<ll, ll>; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define mod 1000000007 #define pi 3.141592653589793 typedef vector<ll> vcl; ll gcd(ll a, ll b) { if (b > a) swap(a, b); if (b == 0) return a; return gcd(b, a % b)...
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<ll, ll>; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define mod 1000000007 #define pi 3.141592653589793 typedef vector<ll> vcl; ll gcd(ll a, ll b) { if (b > a) swap(a, b); if (b == 0) return a; return gcd(b, a % b)...
[["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 98], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 79], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13], ["-", 341, 342, 0, 16, 31, 23, 0, 16, 17, 72], ["+", 341, 342, 0, 16, 31, 23, 0, 16, 17, 33]]
1
367
#include <algorithm> #include <bitset> #include <iostream> #include <string> #include <vector> using namespace std; int main() { int n; cin >> n; vector<int> data(n); for (int i = 0; i < n; i++) cin >> data[i]; sort(data.begin(), data.end(), greater<int>()); long sum = 0; if (n > 1) sum = data...
#include <algorithm> #include <bitset> #include <iostream> #include <string> #include <vector> using namespace std; int main() { int n; cin >> n; vector<int> data(n); for (int i = 0; i < n; i++) cin >> data[i]; sort(data.begin(), data.end(), greater<int>()); long sum = 0; if (n > 1) sum = data...
[["-", 0, 11, 12, 69, 341, 342, 0, 16, 17, 33], ["-", 0, 11, 12, 69, 341, 342, 0, 16, 12, 13], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 17, 85], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 12, 13]]
1
129
import bisect import statistics n = int(input()) a = list((int(x) for x in input().split())) a.sort() incl = [] score = 0 for i in range(len(a)): ain = a.pop() incl.append(ain) if i==0: continue if (len(incl)%2 == 1): score += incl[ int(len(incl))/2 ] else: # smaller of middle two ...
import bisect import statistics n = int(input()) a = list((int(x) for x in input().split())) a.sort() incl = [] score = 0 for i in range(len(a)): ain = a.pop() incl.append(ain) if i==0: continue if (len(incl)%2 == 1): score += incl[ int(len(incl)/2) ] else: # smaller of middle two ...
[["-", 12, 206, 206, 657, 31, 652, 3, 4, 0, 25], ["+", 0, 677, 12, 206, 206, 652, 3, 4, 0, 25]]
5
124
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef pair<int, int> ii; typedef vector<ii> vii; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector<ll> a(n); for (int i = 0; i < n; ++i) cin >> a[i]; sort(a.rbegin(), a.rend()...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef pair<int, int> ii; typedef vector<ii> vii; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector<ll> a(n); for (int i = 0; i < n; ++i) cin >> a[i]; sort(a.rbegin(), a.rend()...
[["+", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35]]
1
187
//デバッグ用オプション:-fsanitize=undefined,address //コンパイラ最適化 #pragma GCC optimize("Ofast") //インクルードなど #include <algorithm> #include <iostream> #include <string> using namespace std; typedef long long ll; // vector set 等 #include <map> #include <set> #include <vector> //マクロ // forループ //引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)...
//デバッグ用オプション:-fsanitize=undefined,address //コンパイラ最適化 #pragma GCC optimize("Ofast") //インクルードなど #include <algorithm> #include <iostream> #include <string> using namespace std; typedef long long ll; // vector set 等 #include <map> #include <set> #include <vector> //マクロ // forループ //引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 0, 21], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 0, 35], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["-", 0, 43, 39, 344, 3, 347, 0, 77, 39, 40], ["+", 39, 344, 3, 347, 0, 77, 39, 86, 0, 96], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
218
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> P; int main() { int n; cin >> n; vector<ll> comfort; for (int i = 0; i < n; i++) { ll a; cin >> a; comfort.push_back(a); } sort(comfort.begin(), comfort.end(), greater<ll>()); ll ans = 0; for (int...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> P; int main() { int n; cin >> n; vector<ll> comfort; for (int i = 0; i < n; i++) { ll a; cin >> a; comfort.push_back(a); } sort(comfort.begin(), comfort.end(), greater<ll>()); ll ans = 0; for (int...
[["-", 0, 11, 12, 69, 341, 342, 0, 16, 17, 72], ["-", 0, 11, 12, 69, 341, 342, 0, 16, 12, 13]]
1
159
#include <algorithm> #include <cmath> #include <cstring> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; typedef long long ll; #define fi first #define se second #define mp make_pair #define r...
#include <algorithm> #include <cmath> #include <cstring> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; typedef long long ll; #define fi first #define se second #define mp make_pair #define r...
[["-", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
1
205
N = int(input()) A = list(map(int, input().split())) A = sorted(A, reverse = True) L = len(P) // 2 if len(A) % 2 == 0: #偶数の時 ans = sum(A[:L]) + sum(A[1:L]) else: #奇数の時 ans = sum(A[:L]) + sum(A[1:L+1]) print(ans)
N = int(input()) A = list(map(int, input().split())) A = sorted(A, reverse = True) L = len(A) // 2 if len(A) % 2 == 0: #偶数の時 ans = sum(A[:L]) + sum(A[1:L]) else: #奇数の時 ans = sum(A[:L]) + sum(A[1:L+1]) print(ans)
[["-", 0, 662, 12, 657, 31, 652, 3, 4, 0, 22], ["+", 0, 662, 12, 657, 31, 652, 3, 4, 0, 22]]
5
103
#include <algorithm> // sort #include <cstring> #include <fstream> #include <iostream> #include <math.h> #include <queue> #include <vector> #define DEBUG 0 #define REP(i, n) for (long long i = 0; i < (n); i++) typedef long long ll; static const ll MOD = 1000000007; static const ll INF = 1000000000000000000LL; // 9999...
#include <algorithm> // sort #include <cstring> #include <fstream> #include <iostream> #include <math.h> #include <queue> #include <vector> #define DEBUG 0 #define REP(i, n) for (long long i = 0; i < (n); i++) typedef long long ll; static const ll MOD = 1000000007; static const ll INF = 1000000000000000000LL; // 9999...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 17, 85], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 12, 13]]
1
156
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; vector<long long> vec(n); for (long long i = 0; i < n; i++) { cin >> vec.at(i); } sort(vec.begin(), vec.end()); reverse(vec.begin(), vec.end()); if (n == 2) { cout << vec.at(0) << endl; return 0; } if (n ...
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; vector<long long> vec(n); for (long long i = 0; i < n; i++) { cin >> vec.at(i); } sort(vec.begin(), vec.end()); reverse(vec.begin(), vec.end()); if (n == 2) { cout << vec.at(0) << endl; return 0; } if (n ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
199
N=int(input()) A=list(map(int,input().split())) A.sort(reverse=True) cnt=2 ans=A[0] i=1 while cnt<N: ans+=A[i] if cnt%2==0: i+=1 cnt+=1 print(ans)
N=int(input()) A=list(map(int,input().split())) A.sort(reverse=True) cnt=2 ans=A[0] i=1 while cnt<N: ans+=A[i] if (cnt+1)%2==0: i+=1 cnt+=1 print(ans)
[["+", 0, 57, 15, 666, 0, 657, 31, 23, 0, 24], ["+", 15, 666, 0, 657, 31, 23, 0, 657, 17, 72], ["+", 15, 666, 0, 657, 31, 23, 0, 657, 12, 612], ["+", 0, 57, 15, 666, 0, 657, 31, 23, 0, 25]]
5
73
import queue ans = 0 N = int(input()) A = list(map(int, input().split())) A.sort(reverse=True) q = queue.LifoQueue() q.put(0) for a in range(len(A)): ans += q.get() q.put(A[a]) if a != 0: q.put(A[a]) print(ans)
import queue ans = 0 N = int(input()) A = list(map(int, input().split())) A.sort(reverse=True) q = queue.Queue() q.put(0) for a in range(len(A)): ans += q.get() q.put(A[a]) if a != 0: q.put(A[a]) print(ans)
[["-", 0, 1, 0, 662, 12, 652, 63, 319, 319, 22], ["+", 0, 1, 0, 662, 12, 652, 63, 319, 319, 22]]
5
96
import math from math import gcd INF = float("inf") import sys input=sys.stdin.readline import itertools from collections import Counter def main(): n = int(input()) a = list(map(int, input().split())) a.sort() ans = 0 + a[-1] for i in range(n-2): k = a[-(i+4)//2] ans += k prin...
import math from math import gcd INF = float("inf") import sys input=sys.stdin.readline import itertools from collections import Counter def main(): n = int(input()) a = list(map(int, input().split())) a.sort() ans = 0 + a[-1] for i in range(n-2): k = a[-((i+4)//2)] ans += k pr...
[["+", 206, 664, 28, 23, 0, 657, 31, 23, 0, 24], ["+", 0, 662, 12, 206, 206, 664, 28, 23, 0, 25]]
5
113
#include <bits/stdc++.h> using namespace std; #define ll long long ll mod = 1e9 + 7, n; map<ll, ll> mp; void dfs(vector<ll> v[], ll idx, ll parent) { for (auto a : v[idx]) { if (a != parent) dfs(v, a, idx); } } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ll a, b; cin >> n; ...
#include <bits/stdc++.h> using namespace std; #define ll long long ll mod = 1e9 + 7, n; map<ll, ll> mp; void dfs(vector<ll> v[], ll idx, ll parent) { for (auto a : v[idx]) { if (a != parent) dfs(v, a, idx); } } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ll a, b; cin >> n; ...
[["-", 0, 11, 12, 69, 341, 342, 0, 16, 17, 33], ["-", 0, 11, 12, 69, 341, 342, 0, 16, 12, 13], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 17, 85], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 12, 13]]
1
179
#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 n; cin >> n; vector<int> a(n); rep(i, n) cin >> a[i]; sort(a.rbegin(), a.rend()); ll ans = 0; for (int i = 1; i < n; i++) ans += a[i]; cout ...
#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 n; cin >> n; vector<int> a(n); rep(i, n) cin >> a[i]; sort(a.rbegin(), a.rend()); ll ans = 0; for (int i = 1; i < n; i++) ans += a[i / 2]; c...
[["+", 0, 11, 12, 69, 341, 342, 0, 16, 17, 85], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 12, 13]]
1
116
n = int(input()) a = list(map(int, input().split())) aa = sorted(a, reverse=True) # print(aa) ans = 0 for i in range(n-1): ans += a[(i + 1) // 2] # print(ans) print(ans)
n = int(input()) a = list(map(int, input().split())) aa = sorted(a, reverse=True) # print(aa) ans = 0 for i in range(n-1): ans += aa[(i + 1) // 2] # print(ans) print(ans)
[["-", 8, 196, 0, 1, 0, 677, 12, 206, 51, 22], ["+", 8, 196, 0, 1, 0, 677, 12, 206, 51, 22]]
5
66
N = int(input()) A = list(map(int, input().split())) A.sort(reverse = True) ans = A[0] if N%2 == 0: for i in range(1,int(N/2)): ans = ans + A[i]*2 if N%2 == 1: for i in range(1,int((N-1)/2)): ans = ans + A[i]*2 ans += A[(N+1)/2] print(ans)
N = int(input()) A = list(map(int, input().split())) A.sort(reverse = True) ans = A[0] if N%2 == 0: for i in range(1,int(N/2)): ans = ans + A[i]*2 if N%2 == 1: for i in range(1,int((N-1)/2)): ans = ans + A[i]*2 ans += A[int((N-1)/2)] print(ans)
[["+", 0, 1, 0, 677, 12, 206, 206, 652, 63, 22], ["+", 0, 677, 12, 206, 206, 652, 3, 4, 0, 24], ["-", 12, 206, 206, 657, 31, 23, 0, 657, 17, 72], ["+", 3, 4, 0, 657, 31, 23, 0, 657, 17, 33], ["+", 0, 677, 12, 206, 206, 652, 3, 4, 0, 25]]
5
123
#include <bits/stdc++.h> #define rep(i, N) for (int i = 0; i < (N); i++) #define FOR(i, a, b) for (int i = (a); i < (b); i++) using namespace std; const long long MOD = 1e9 + 7; const long long INF = 1e12; const int inf = 1e9; const int mod = 1e9 + 7; typedef long long ll; typedef pair<ll, int> P; typedef set<int> S; i...
#include <bits/stdc++.h> #define rep(i, N) for (int i = 0; i < (N); i++) #define FOR(i, a, b) for (int i = (a); i < (b); i++) using namespace std; const long long MOD = 1e9 + 7; const long long INF = 1e12; const int inf = 1e9; const int mod = 1e9 + 7; typedef long long ll; typedef pair<ll, int> P; typedef set<int> S; i...
[["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 45], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 46]]
1
201
//インクルード(アルファベット順) #include <algorithm> //sort,二分探索,など #include <bitset> //固定長bit集合 #include <chrono> //実行時間計測 #include <cmath> //pow,logなど #include <complex> //複素数 #include <deque> //両端アクセスのキュー #include <functional> //sortのgreater #include <iomanip> //setprecision(浮動小数点...
//インクルード(アルファベット順) #include <algorithm> //sort,二分探索,など #include <bitset> //固定長bit集合 #include <chrono> //実行時間計測 #include <cmath> //pow,logなど #include <complex> //複素数 #include <deque> //両端アクセスのキュー #include <functional> //sortのgreater #include <iomanip> //setprecision(浮動小数点...
[["-", 0, 1, 0, 16, 31, 16, 12, 16, 17, 33], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["+", 12, 16, 12, 69, 341, 342, 0, 16, 17, 72], ["+", 12, 16, 12, 69, 341, 342, 0, 16, 12, 13]]
1
567
import sys def input(): return sys.stdin.readline().strip() def mapint(): return map(int, input().split()) sys.setrecursionlimit(10**9) N = int(input()) As = list(mapint()) conf = 0 from heapq import heapify, heappop, heappush As.sort(reverse=True) m = As.pop(0) s = As.pop(0) conf += m Q = [] heappush(Q, s) heappush(...
import sys def input(): return sys.stdin.readline().strip() def mapint(): return map(int, input().split()) sys.setrecursionlimit(10**9) N = int(input()) As = list(mapint()) conf = 0 from heapq import heapify, heappop, heappush As.sort(reverse=True) m = As.pop(0) s = As.pop(0) conf += m Q = [] heappush(Q, -s) heappush...
[["+", 0, 1, 0, 652, 3, 4, 0, 664, 17, 33], ["-", 0, 7, 8, 196, 0, 1, 0, 677, 17, 107], ["+", 0, 7, 8, 196, 0, 1, 0, 677, 17, 110]]
5
145
N = int(input()) A = list(map(int,input().split())) A.sort(reverse=True) B = [A[0]] for i in range(N): B.append(A[1]) B.append(A[1]) ans = 0 for i in range(N-1): ans += B[i] print(ans)
N = int(input()) A = list(map(int,input().split())) A.sort(reverse=True) B = [A[0]] for i in range(N-1): B.append(A[i+1]) B.append(A[i+1]) #print(B) ans = 0 for i in range(N-1): ans += B[i] print(ans)
[["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612], ["+", 0, 652, 3, 4, 0, 206, 206, 657, 31, 22], ["+", 0, 652, 3, 4, 0, 206, 206, 657, 17, 72]]
5
90
#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 n; cin >> n; vector<int> a(n); rep(i, n) cin >> a[i]; sort(a.rbegin(), a.rend()); ll ans = 0; int t = n - 1; rep(i, n) { int lim = 2; if ...
#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 n; cin >> n; vector<int> a(n); rep(i, n) cin >> a[i]; sort(a.rbegin(), a.rend()); ll ans = 0; int t = n - 1; rep(i, n) { int lim = 2; if ...
[["-", 0, 14, 8, 9, 0, 14, 8, 9, 0, 46], ["+", 0, 14, 8, 9, 0, 57, 64, 9, 0, 46]]
1
151
N = int(input()) nums = list(map(int, input().split())) nums.sort(reverse=True) score = nums[0] + sum(nums[1:N//2]) if N%2 != 0: score += nums[N//2] print(score)
N = int(input()) nums = list(map(int, input().split())) nums.sort(reverse=True) score = nums[0] + 2 * sum(nums[1:N//2]) if N%2 != 0: score += nums[N//2] print(score)
[["+", 0, 1, 0, 662, 12, 657, 12, 657, 31, 612], ["+", 0, 1, 0, 662, 12, 657, 12, 657, 17, 48]]
5
70
N = int(input()) a = sorted(list(map(int, input().split())), reverse=True) ans = 0 for i in range(n-1): ans += a[(i+1)//2] print(ans)
N = int(input()) a = sorted(list(map(int, input().split())), reverse=True) ans = 0 for i in range(N-1): ans += a[(i+1)//2] print(ans)
[["-", 0, 7, 12, 652, 3, 4, 0, 657, 31, 22], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 31, 22]]
5
61
#!/usr/bin/env python3 import sys sys.setrecursionlimit(10**7) import bisect import heapq import itertools import math from collections import Counter, defaultdict, deque from copy import deepcopy from decimal import Decimal from math import gcd from operator import add, itemgetter, mul, xor def cmb(n,r,mod): bunshi=...
#!/usr/bin/env python3 import sys sys.setrecursionlimit(10**7) import bisect import heapq import itertools import math from collections import Counter, defaultdict, deque from copy import deepcopy from decimal import Decimal from math import gcd from operator import add, itemgetter, mul, xor def cmb(n,r,mod): bunshi=...
[["-", 0, 1, 0, 677, 12, 206, 206, 657, 17, 109], ["+", 0, 1, 0, 677, 12, 206, 206, 657, 17, 676]]
5
253
import heapq #入力:[n1,n2,...nk](int:整数配列) def input_array(): return list(map(int,input().split())) n=int(input()) A=input_array() sortA=sorted(A,reverse=True) #降順にソート ans=0 q=[] heapq.heappush(q,-sortA[0]) for i in range(1,n): tmp=heapq.heappop(q) tmp*=-1 ans+=tmp heapq.heappush(q,-sortA[i]) heapq.heappush(q,-...
import heapq #入力:[n1,n2,...nk](int:整数配列) def input_array(): return list(map(int,input().split())) n=int(input()) A=input_array() sortA=sorted(A,reverse=True) #降順にソート ans=0 q=[] heapq.heappush(q,-sortA[0]) for i in range(1,n): tmp=heapq.heappop(q) tmp*=-1 ans+=tmp heapq.heappush(q,-sortA[i]) heapq.heappush(q,-...
[["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25], ["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24]]
5
124
class PriorityQueue def initialize(array = []) @data = [] array.each{|a| add(a)} end def add(element) @data.push(element) bottom_up end def peek @data[0] end def poll if size == 0 return nil elsif size == 1 return @data.pop else min = @data[0] @da...
class PriorityQueue def initialize(array = []) @data = [] array.each{|a| add(a)} end def add(element) @data.push(element) bottom_up end def peek @data[0] end def poll if size == 0 return nil elsif size == 1 return @data.pop else min = @data[0] @da...
[["+", 31, 516, 0, 767, 0, 569, 51, 748, 17, 33], ["+", 196, 737, 8, 736, 0, 755, 12, 748, 17, 33], ["+", 3, 4, 0, 767, 0, 569, 51, 748, 17, 33]]
4
466
import heapq n = int(input()) A = list(map(int, input().split())) A = sorted(A, reverse=True) ans = 0 q = [] heapq.heappush(q, A[0]*-1) for i in range(1, n): print(q) tmp = heapq.heappop(q) ans += tmp heapq.heappush(q, A[i] * -1) heapq.heappush(q, A[i] * -1) print(ans*-1)
import heapq n = int(input()) A = list(map(int, input().split())) A = sorted(A, reverse=True) ans = 0 q = [] heapq.heappush(q, A[0]*-1) for i in range(1, n): tmp = heapq.heappop(q) ans += tmp heapq.heappush(q, A[i] * -1) heapq.heappush(q, A[i] * -1) print(ans*-1)
[["-", 0, 7, 8, 196, 0, 1, 0, 652, 63, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
5
118
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define printVec(v) \ printf("{"); \ for (const auto &i : v) { \ ...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define printVec(v) \ printf("{"); \ for (const auto &i : v) { \ ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
260
n=int(input()) A=[] A=list(map(int, input().split())) # print(A) mina = min( A ) maxa = max( A ) A.sort() A.reverse() sum = 0 for i in range(n): sum +=A[(i+1)//2] # print(A[(i+1)//2]) # print(mina) # print(maxa) # print(sum) print(sum)
n=int(input()) A=[] A=list(map(int, input().split())) # print(A) mina = min( A ) maxa = max( A ) A.sort() A.reverse() sum = 0 for i in range(n-1): sum +=A[(i+1)//2] # print(A[(i+1)//2]) # print(mina) # print(maxa) # print(sum) print(sum)
[["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
83
import math N = int(input()) A = sorted(list(map(int, input().split())),reverse=True) s = A[0] for i in range(1,N): s += A[math.ceil(i/2)] print(s)
import math N = int(input()) A = sorted(list(map(int, input().split())),reverse=True) s = A[0] for i in range(1,N-1): s += A[math.ceil(i/2)] print(s)
[["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
67
#include <bits/stdc++.h> using namespace std; int main() { int n, x; vector<int> arr; cin >> n; for (int i = 0; i < n; i++) { cin >> x; arr.push_back(x); } sort(arr.begin(), arr.end()); reverse(arr.begin(), arr.end()); int ans = arr[0]; n -= 2; int k = 1; while (1) { if (n == 0) { ...
#include <bits/stdc++.h> using namespace std; int main() { int n, x; vector<int> arr; cin >> n; for (int i = 0; i < n; i++) { cin >> x; arr.push_back(x); } sort(arr.begin(), arr.end()); reverse(arr.begin(), arr.end()); long long ans = arr[0]; n -= 2; int k = 1; while (1) { if (n == 0)...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35], ["+", 0, 52, 8, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 27, 17, 29]]
1
160
#include <bits/stdc++.h> #define ll long long using namespace std; const int N = (int)2 * 1e5 + 50; struct Pos { int lf, rf, comfort; inline Pos(int l, int r) { lf = l, rf = r; comfort = min(l, r); } inline bool operator<(const Pos &p) const { return comfort < p.comfort; } }; priority_queue<Pos> q; inli...
#include <bits/stdc++.h> #define ll long long using namespace std; const int N = (int)2 * 1e5 + 50; struct Pos { int lf, rf, comfort; inline Pos(int l, int r) { lf = l, rf = r; comfort = min(l, r); } inline bool operator<(const Pos &p) const { return comfort < p.comfort; } }; priority_queue<Pos> q; inli...
[["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
367
n=int(input()) a=list(map(int.input().split())) a.sort(reverse=True) ans=0 x=n for i in range(1,n): ans+=a[i//2] print(ans)
n=int(input()) a=list(map(int,input().split())) a.sort(reverse=True) ans=0 x=n for i in range(1,n): ans+=a[i//2] print(ans)
[["-", 0, 652, 63, 319, 500, 652, 63, 319, 0, 131], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 21]]
5
61
#include <bits/stdc++.h> using namespace std; #define debug(x) cerr << x << " = "(x) << endl; #define ll long long #define rep(i, x, y) for (int i = x; i < y; i++) #define rel(i, x, y) for (int i = x - 1; i >= y; i--) #define all(x) x.begin(), x.end() int main() { cin.tie(nullptr); ios::sync_with_stdio(false); ...
#include <bits/stdc++.h> using namespace std; #define debug(x) cerr << x << " = "(x) << endl; #define ll long long #define rep(i, x, y) for (int i = x; i < y; i++) #define rel(i, x, y) for (int i = x - 1; i >= y; i--) #define all(x) x.begin(), x.end() int main() { cin.tie(nullptr); ios::sync_with_stdio(false); ...
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["-", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 57, 64, 9, 0, 1, 0, 27, 17, 29]]
1
188
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define N 0 #define INF 0x3f3f3f3f #define LL long long #define mz(x) ms(x, 0) #define ms(x, y) memset(x,...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define N 0 #define INF 0x3f3f3f3f #define LL long long #define mz(x) ms(x, 0) #define ms(x, y) memset(x,...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13], ["+", 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
209
n = int(input()) a = sorted(list(map(int, input().split())), reverse = True) ans = 0 for i in range(1, n): ans += a[i-1] print(ans)
n = int(input()) a = sorted((list(map(int, input().split()))), reverse = True) ans = 0 for i in range(1, n): ans += a[i//2] print(ans)
[["+", 0, 662, 12, 652, 3, 4, 0, 23, 0, 24], ["+", 0, 662, 12, 652, 3, 4, 0, 23, 0, 25], ["-", 0, 1, 0, 677, 12, 206, 206, 657, 17, 33], ["-", 0, 1, 0, 677, 12, 206, 206, 657, 12, 612], ["+", 0, 1, 0, 677, 12, 206, 206, 657, 17, 676], ["+", 0, 1, 0, 677, 12, 206, 206, 657, 12, 612]]
5
57
#include <bits/stdc++.h> using namespace std; #define all(x) x.begin(), x.end() #define sz(x) (int)x.size() #define pb push_back #define endl '\n' #define snd second #define fst first #define fastio cin.tie(NULL), cout.sync_with_stdio(true) typedef long long int ll; typedef unsigned long long int ull; typedef vector...
#include <bits/stdc++.h> using namespace std; #define all(x) x.begin(), x.end() #define sz(x) (int)x.size() #define pb push_back #define endl '\n' #define snd second #define fst first #define fastio cin.tie(NULL), cout.sync_with_stdio(true) typedef long long int ll; typedef unsigned long long int ull; typedef vector...
[["-", 0, 1, 0, 2, 3, 4, 0, 66, 17, 48], ["+", 0, 2, 3, 4, 0, 2, 63, 343, 345, 348], ["+", 0, 2, 3, 4, 0, 2, 63, 343, 0, 349], ["+", 0, 2, 3, 4, 0, 2, 63, 343, 141, 22], ["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 24], ["-", 3, 4, 0, 66, 28, 2, 63, 118, 119, 120], ["+", 0, 2, 3, 4, 0, 2, 63, 118, 119, 120], ["+", 0, 2, 3, 4, 0, 2...
1
268
//#pragma GCC target ("avx2") //#pragma GCC optimization ("O3") //#pragma GCC optimization ("unroll-loops") #include <bits/stdc++.h> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> // using namespace __gnu_pbds; #define eps 1e-8 #define eq(x, y) (fabs((x) - (y)) < eps) using namespace ...
//#pragma GCC target ("avx2") //#pragma GCC optimization ("O3") //#pragma GCC optimization ("unroll-loops") #include <bits/stdc++.h> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> // using namespace __gnu_pbds; #define eps 1e-8 #define eq(x, y) (fabs((x) - (y)) < eps) using namespace ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
218
import numpy as np N = int(input()) A = np.array([int(i) for i in input().split()]) A_sort = np.sort(A) print(A_sort) score = 0 score += A_sort[-1] for i in range(0, (N-2)//2): score += A_sort[-2-i] * 2 if (N-2) % 2 == 1: score += A_sort[-3-i] print(score)
import numpy as np N = int(input()) A = np.array([int(i) for i in input().split()]) A_sort = np.sort(A) #print(A_sort) score = 0 score += A_sort[-1] for i in range(0, (N-2)//2): score += A_sort[-2-i] * 2 if (N-2) % 2 == 1: score += A_sort[-3-i] print(score)
[["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]]
5
108
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> ii; int main() { ll n; scanf("%lld", &n); int inp[n]; for (int i = 0; i < n; i++) scanf("%d", &inp[i]); sort(inp, inp + n, greater<int>()); ll ans = 0; /* WA int mx1 = inp[0]; int mx2 = INT_MAX; for (i...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> ii; int main() { ll n; scanf("%lld", &n); int inp[n]; for (int i = 0; i < n; i++) scanf("%d", &inp[i]); sort(inp, inp + n, greater<int>()); ll ans = 0; /* WA int mx1 = inp[0]; int mx2 = INT_MAX; for (i...
[["-", 0, 11, 12, 69, 341, 342, 0, 16, 31, 22], ["-", 0, 11, 12, 69, 341, 342, 0, 16, 17, 33], ["-", 12, 69, 341, 342, 0, 16, 12, 23, 0, 24], ["-", 12, 69, 341, 342, 0, 16, 12, 23, 0, 25]]
1
136
# -*- coding: utf-8 -*- import math # import copy # 引数が一つだけのやつ n = int(input()) # 引数が複数あるやつ(全部数字) target_1 = [int(x) for x in input().split()] # 引数が複数あるやつ(そうじゃないの) # target = [int(x) for x in input().split()] # number = int(input()) # 複数行を受け取って処理するやつ # target = [list(input()) for i in range(H)] # 関数 def count_sha...
# -*- coding: utf-8 -*- import math # import copy # 引数が一つだけのやつ n = int(input()) # 引数が複数あるやつ(全部数字) target_1 = [int(x) for x in input().split()] # 引数が複数あるやつ(そうじゃないの) # target = [int(x) for x in input().split()] # number = int(input()) # 複数行を受け取って処理するやつ # target = [list(input()) for i in range(H)] # 関数 def count_sha...
[["-", 0, 677, 12, 206, 206, 664, 28, 23, 0, 24], ["-", 12, 206, 206, 664, 28, 23, 0, 657, 17, 72], ["+", 0, 1, 0, 677, 12, 206, 206, 657, 17, 33], ["-", 28, 23, 0, 657, 12, 652, 3, 4, 0, 25], ["+", 206, 657, 12, 652, 3, 4, 0, 657, 17, 85], ["+", 206, 657, 12, 652, 3, 4, 0, 657, 12, 612]]
5
143
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound #include <bitset> // bitset #include <cctype> // isupper, islower, isdigit, toupper, tolower #include <cmath> //sqrt pow #include <cstdint> // int64_t, int*_t #include <cstdio> // printf #include <deque> // dequef #includ...
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound #include <bitset> // bitset #include <cctype> // isupper, islower, isdigit, toupper, tolower #include <cmath> //sqrt pow #include <cstdint> // int64_t, int*_t #include <cstdio> // printf #include <deque> // dequef #includ...
[["-", 0, 11, 12, 69, 341, 342, 0, 16, 17, 33], ["+", 12, 69, 341, 342, 0, 16, 31, 16, 17, 85], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 17, 33], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 12, 13], ["+", 12, 69, 341, 342, 0, 16, 31, 16, 12, 13]]
1
223
#include <bits/stdc++.h> using namespace std; // conversion //------------------------------------------ inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } // math //--------...
#include <bits/stdc++.h> using namespace std; // conversion //------------------------------------------ inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template <class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } // math //--------...
[["+", 0, 11, 12, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 11, 12, 2, 3, 4, 0, 16, 12, 13]]
1
1,099
#include <bits/stdc++.h> #define rep(X, N) for (ll X = 0LL; X < (N); X++) #define ALL(V) (V).begin(), (V).end() using namespace std; typedef long long ll; const double PI = 3.1415926535897932384626; const ll MODN = 1000000007; const ll MODN2 = 998244353; const double EPS = 1e-10; int main() { int n; cin >> n; ...
#include <bits/stdc++.h> #define rep(X, N) for (ll X = 0LL; X < (N); X++) #define ALL(V) (V).begin(), (V).end() using namespace std; typedef long long ll; const double PI = 3.1415926535897932384626; const ll MODN = 1000000007; const ll MODN2 = 998244353; const double EPS = 1e-10; int main() { int n; cin >> n; ...
[["-", 12, 69, 341, 342, 0, 16, 31, 23, 0, 24], ["-", 341, 342, 0, 16, 31, 23, 0, 16, 17, 72], ["-", 341, 342, 0, 16, 31, 23, 0, 16, 12, 13], ["-", 12, 69, 341, 342, 0, 16, 31, 23, 0, 25]]
1
152
#include <algorithm> #include <iostream> #include <vector> int main(void) { long long int n; std::cin >> n; std::vector<long long int> A(n); for (long long int i = 0; i < n; i++) { std::cin >> A[i]; } std::sort(A.begin(), A.end(), std::greater<long long int>()); long long int ans = A[0]; long lon...
#include <algorithm> #include <iostream> #include <vector> int main(void) { long long int n; std::cin >> n; std::vector<long long int> A(n); for (long long int i = 0; i < n; i++) { std::cin >> A[i]; } std::sort(A.begin(), A.end(), std::greater<long long int>()); long long int ans = A[0]; long lon...
[["-", 0, 11, 12, 69, 341, 342, 0, 16, 31, 13], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 31, 13]]
1
174
#include <bits/stdc++.h> using namespace std; #define rep(i, b) for (long long i = 0; i < (b); i++) #define all(a) a.begin(), a.end() #define allr(a) a.rbegin(), a.rend() using ll = long long; string s; ll lcm(ll a, ll b) { return (a * b) / (__gcd(a, b)); } void solve() { int n; cin >> n; vector<int> v(n); r...
#include <bits/stdc++.h> using namespace std; #define rep(i, b) for (long long i = 0; i < (b); i++) #define all(a) a.begin(), a.end() #define allr(a) a.rbegin(), a.rend() using ll = long long; string s; ll lcm(ll a, ll b) { return (a * b) / (__gcd(a, b)); } void solve() { int n; cin >> n; vector<int> v(n); r...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["-", 75, 76, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 75, 76, 0, 57, 15, 339, 51, 16, 17, 60]]
1
204
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a.begin(), a.end(), greater<int>()); int ans = 0; for (int i = 1; i < n; i++) { ans += a[i - 1]; } cout << a...
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { long long n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a.begin(), a.end(), greater<int>()); long long ans = 0; for (int i = 1; i < n; i++) { ans += a[i / 2]; } ...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["-", 0, 11, 12, 69, 341, 342, 0, 16, 17, 33], ["-", 0, 11, 12, 69, 341, 342, 0, 16, 12, 13], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 17, 85], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 12, 13]]
1
113
N = int(input()) A = list(map(int, input().split())) A.sort(reverse = True) ans = A[0] idx = 1 cnt = 0 for i in range(2,N): ans += A[idx] cnt += 1 if cnt == 2: idx += 1 c = 0 print(ans)
N = int(input()) A = list(map(int, input().split())) A.sort(reverse = True) ans = A[0] idx = 1 cnt = 0 for i in range(2,N): ans += A[idx] cnt += 1 if cnt == 2: idx += 1 cnt = 0 print(ans)
[["-", 0, 57, 64, 196, 0, 1, 0, 662, 31, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 31, 22]]
5
79
n = int(input()) a = list(map(int, input().split())) a = sorted(a)[::-1] ans = 2 * sum(a[1:n // 2]) + a[0] if n % 2 == 1: ans += a[n // 2 + 1] print(ans)
n = int(input()) a = list(map(int, input().split())) a = sorted(a)[::-1] ans = 2 * sum(a[1:n // 2]) + a[0] if n % 2 == 1: ans += a[n // 2] print(ans)
[["-", 0, 1, 0, 677, 12, 206, 206, 657, 17, 72], ["-", 0, 1, 0, 677, 12, 206, 206, 657, 12, 612]]
5
78
#include <bits/stdc++.h> using namespace std; #define SORT(A) std::sort(A.begin(), A.end()) #define RSORT(A) std::sort(A.begin(), A.end(), std::greater<>()) #define FR(A, e) for (auto &e : A) #define SHOW(A) \ for (auto &e : A) { ...
#include <bits/stdc++.h> using namespace std; #define SORT(A) std::sort(A.begin(), A.end()) #define RSORT(A) std::sort(A.begin(), A.end(), std::greater<>()) #define FR(A, e) for (auto &e : A) #define SHOW(A) \ for (auto &e : A) { ...
[["+", 8, 9, 0, 1, 0, 11, 12, 23, 0, 24], ["+", 8, 9, 0, 1, 0, 11, 12, 23, 0, 25], ["-", 0, 16, 12, 69, 341, 342, 0, 16, 17, 72], ["-", 0, 16, 12, 69, 341, 342, 0, 16, 12, 13]]
1
411
N = int(input()) A = list(map(int, input().split())) A.sort() A.reverse() if (N-1) % 2 == 0: ans = sum(A[1:(N-1)//2]) * 2 + A[0] + A[(N-1) // 2 + 1] else: ans = A[0] + sum(A[1:N // 2 ]) * 2 print(ans)
N = int(input()) A = list(map(int, input().split())) A.sort() A.reverse() if (N-1) % 2 == 0: ans = sum(A[1:(N-1)//2]) * 2 + A[0] + A[(N-1) // 2] else: ans = A[0] + sum(A[1:N // 2 ]) * 2 print(ans)
[["-", 0, 662, 12, 657, 12, 206, 206, 657, 17, 72], ["-", 0, 662, 12, 657, 12, 206, 206, 657, 12, 612]]
5
109
#include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define rep(i, n) FOR(i, 0, n) #define req(i, n) for (int i = 1; i <= n; i++) #define pai 3.14159265358979323846 const int INF = 1001001001; typedef long long ll; int A[3][3], N; bool punched[3][3]; bool ok[3][3]; using G...
#include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define rep(i, n) FOR(i, 0, n) #define req(i, n) for (int i = 1; i <= n; i++) #define pai 3.14159265358979323846 const int INF = 1001001001; typedef long long ll; int A[3][3], N; bool punched[3][3]; bool ok[3][3]; using G...
[["-", 75, 76, 0, 9, 0, 1, 0, 11, 12, 13], ["+", 75, 76, 0, 9, 0, 1, 0, 11, 12, 13]]
1
553
n=int(input()) a=list(map(int,input().split())) a.sort() a.reverse() ans = 0 for i in range(1,n+1): ans += a[i//2] print(ans)
n=int(input()) a=list(map(int,input().split())) a.sort() a.reverse() ans = 0 for i in range(1,n): ans += a[i//2] print(ans)
[["-", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
62
#include <bits/stdc++.h> using ll = long long; using namespace std; int main() { int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n, greater<int>()); ll ans = 0; for (int i = 0; i < n; i++) ans += a[(i + 1) / 2]; cout << ans << endl; return 0; }
#include <bits/stdc++.h> using ll = long long; using namespace std; int main() { int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n, greater<int>()); ll ans = 0; for (int i = 0; i < n - 1; i++) ans += a[(i + 1) / 2]; cout << ans << endl; return 0; }
[["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
1
109
#include <algorithm> #include <iostream> #include <vector> #define ll long long using namespace std; int main() { int N; cin >> N; vector<ll> A(N); for (int i = 0; i < N; i++) { cin >> A[i]; } sort(A.begin(), A.end(), greater<ll>()); ll ans = A[0]; for (int i = 1; i <= (N - 2) / 2; i++) ans +=...
#include <algorithm> #include <iostream> #include <vector> #define ll long long using namespace std; int main() { int N; cin >> N; vector<ll> A(N); for (int i = 0; i < N; i++) { cin >> A[i]; } sort(A.begin(), A.end(), greater<ll>()); ll ans = A[0]; for (int i = 1; i <= (N - 2) / 2; i++) ans +=...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 33], ["-", 15, 339, 51, 16, 31, 16, 12, 16, 31, 13]]
1
145
#include <bits/stdc++.h> #define two(a) (1 << (a)) #define LINF (1ll << 61) #define EPS (1e-14) #define Lshift(a, b) ((a) << (b)) #define Rshift(a, b) ((a) >> (b)) #define rep(a, b) for (a = 0; a < b; a++) #define xrep(a, b, c) for (a = b; a < c; a++) #define INF (1 << 29) #define sz(a) int(a.size()) #define mset(x) me...
#include <bits/stdc++.h> #define two(a) (1 << (a)) #define LINF (1ll << 61) #define EPS (1e-14) #define Lshift(a, b) ((a) << (b)) #define Rshift(a, b) ((a) >> (b)) #define rep(a, b) for (a = 0; a < b; a++) #define xrep(a, b, c) for (a = b; a < c; a++) #define INF (1 << 29) #define sz(a) int(a.size()) #define mset(x) me...
[["-", 0, 14, 8, 9, 0, 1, 0, 27, 17, 68], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 17, 110], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13]]
1
250
n = int(input()) friend = list(map(int, input().split())) friend.sort(reverse = True) ans = friend[0] i = 1 ind = 1 while i < n: for j in range(2): ans += friend[ind] i += 1 if i == n: break ind += 1 print(ans)
n = int(input()) friend = list(map(int, input().split())) friend.sort(reverse = True) ans = friend[0] i = 1 ind = 1 while i < n - 1: for j in range(2): ans += friend[ind] i += 1 if i == n-1: break ind += 1 print(ans)
[["+", 0, 656, 0, 52, 15, 666, 0, 657, 17, 33], ["+", 0, 656, 0, 52, 15, 666, 0, 657, 12, 612], ["+", 8, 196, 0, 57, 15, 666, 0, 657, 17, 33], ["+", 8, 196, 0, 57, 15, 666, 0, 657, 12, 612]]
5
80
#include <bits/stdc++.h> using namespace std; using ll = long long; #define INT(...) \ int __VA_ARGS__; \ in(__VA_ARGS__) #define LL(...) ...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define INT(...) \ int __VA_ARGS__; \ in(__VA_ARGS__) #define LL(...) ...
[["+", 12, 69, 341, 342, 0, 16, 31, 23, 0, 25], ["-", 0, 11, 12, 69, 341, 342, 0, 23, 0, 25]]
1
956
N = int(input()) A = map(int, input().split()) A = sorted(A) A = A[::-1] sumkoko = A.pop(0) sumkoko += sum(A[0:(N-1)//2]) * 2 if ((N-1)%2) == 1: sumkoko += A[(N-1)//2] print(sumkoko)
N = int(input()) A = map(int, input().split()) A = sorted(A) A = A[::-1] sumkoko = A.pop(0) sumkoko += sum(A[0:(N-2)//2]) * 2 if ((N-2)%2) == 1: sumkoko += A[(N-2)//2] print(sumkoko)
[["-", 206, 663, 0, 657, 31, 23, 0, 657, 12, 612], ["+", 206, 663, 0, 657, 31, 23, 0, 657, 12, 612], ["-", 0, 23, 0, 657, 31, 23, 0, 657, 12, 612], ["+", 0, 23, 0, 657, 31, 23, 0, 657, 12, 612], ["-", 12, 206, 206, 657, 31, 23, 0, 657, 12, 612], ["+", 12, 206, 206, 657, 31, 23, 0, 657, 12, 612]]
5
93
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools import time,random,resource sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**10 mod = 10**9+7 dd = [(-1,0),(0,1),(1,0),(0,-1)] ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)] def LI(): return list(map(in...
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools import time,random,resource sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**10 mod = 10**9+7 dd = [(-1,0),(0,1),(1,0),(0,-1)] ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)] def LI(): return list(map(in...
[["-", 0, 37, 0, 657, 12, 206, 206, 657, 17, 33], ["-", 0, 37, 0, 657, 12, 206, 206, 657, 12, 612]]
5
479
import java.util.Arrays; import java.util.HashMap; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner s = new Scanner(System.in); int n = s.nextInt(); int a[] = new int[n]; for (int i = 0; i < n; i++) { a[i] = s.nextInt(); } Arrays.parallelSo...
import java.util.Arrays; import java.util.HashMap; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner s = new Scanner(System.in); int n = s.nextInt(); int a[] = new int[n]; for (int i = 0; i < n; i++) { a[i] = s.nextInt(); } Arrays.parallelSo...
[["-", 64, 196, 0, 1, 0, 11, 12, 504, 71, 499], ["+", 64, 196, 0, 1, 0, 11, 12, 504, 71, 22]]
3
178
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<long long> vl; #define pll pair<ll, ll> #define vpll vector<pll> #define vb vector<bool> #define PB push_back #define MP make_pair #define ln "\n" #define forn(i, e) for (ll i = 0; i < e; i++) #define forsn(i, s, e) for (ll i = s; i < e;...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<long long> vl; #define pll pair<ll, ll> #define vpll vector<pll> #define vb vector<bool> #define PB push_back #define MP make_pair #define ln "\n" #define forn(i, e) for (ll i = 0; i < e; i++) #define forsn(i, s, e) for (ll i = s; i < e;...
[["-", 0, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 0, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
457
N = int(input()) A = list(map(int,input().split())) A.sort(reverse=True) score = 0 score += A[0] for i in range(1,int(N/2)): score += A[i]*2 if N%2 == 1: score += A[round(N/2)] print(score)
N = int(input()) A = list(map(int,input().split())) A.sort(reverse=True) score = 0 score += A[0] for i in range(1,int(N/2)): score += A[i]*2 if N%2 == 1: score += A[int(N/2)] print(score)
[["-", 0, 1, 0, 677, 12, 206, 206, 652, 63, 22], ["+", 0, 1, 0, 677, 12, 206, 206, 652, 63, 22]]
5
87
#include <bits/stdc++.h> #define rep(i, n) for (ll i = 0; i < n; ++i) typedef long long ll; using namespace std; const int INF = 1e9; int main() { int n; cin >> n; vector<ll> a(n); rep(i, n) cin >> a[i]; sort(a.rbegin(), a.rend()); ll ans = a[0]; ll sa = 0; for (int i = 1; i < (n + 1) / 2; ++i) { ...
#include <bits/stdc++.h> #define rep(i, n) for (ll i = 0; i < n; ++i) typedef long long ll; using namespace std; const int INF = 1e9; int main() { int n; cin >> n; vector<ll> a(n); rep(i, n) cin >> a[i]; sort(a.rbegin(), a.rend()); ll ans = a[0]; ll sa = 0; for (int i = 1; i < (n + 1) / 2; ++i) { ...
[["+", 51, 16, 12, 16, 31, 16, 31, 23, 0, 24], ["+", 12, 16, 31, 16, 31, 23, 0, 16, 17, 72], ["+", 12, 16, 31, 16, 31, 23, 0, 16, 12, 13], ["+", 51, 16, 12, 16, 31, 16, 31, 23, 0, 25]]
1
158
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ll n; cin >> n; ll arr[n]; for (ll i = 0; i < n; ++i) { cin >> arr[i]; } sort(arr, arr + n, greater<ll>()); ll ans = 0; for (ll i = 1; i < n; ++i) { ans += arr[i - 1]; } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ll n; cin >> n; ll arr[n]; for (ll i = 0; i < n; ++i) { cin >> arr[i]; } sort(arr, arr + n, greater<ll>()); ll ans = 0; for (ll i = 1; i < n; ++i) { ans += arr[i / 2]; } cout << ans; return 0; }
[["-", 0, 11, 12, 69, 341, 342, 0, 16, 17, 33], ["-", 0, 11, 12, 69, 341, 342, 0, 16, 12, 13], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 17, 85], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 12, 13]]
1
107
/*input 1 1 */ /* ______________ | ) | ) / |______/ ...
/*input 1 1 */ /* ______________ | ) | ) / |______/ ...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 17, 48], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 12, 13]]
1
654
#include <algorithm> #include <cmath> #include <complex> #include <functional> #include <iostream> #include <limits> #include <numeric> #include <sstream> #include <string> #include <vector> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int N; cin >> N...
#include <algorithm> #include <cmath> #include <complex> #include <functional> #include <iostream> #include <limits> #include <numeric> #include <sstream> #include <string> #include <vector> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int N; cin >> N...
[["+", 12, 69, 341, 342, 0, 16, 31, 23, 0, 24], ["+", 341, 342, 0, 16, 31, 23, 0, 16, 17, 33], ["+", 341, 342, 0, 16, 31, 23, 0, 16, 12, 13], ["+", 12, 69, 341, 342, 0, 16, 31, 23, 0, 25]]
1
151
n = int(input()) a = list(map(int, input().split())) a.sort(reverse=True) ans = a[0] cnt = 0 for i in range(2, n): j = 1 if cnt < 2: ans += a[i-j-cnt] cnt += 1 if cnt == 2: cnt = 0 j += 1 print(ans)
n = int(input()) a = list(map(int, input().split())) a.sort(reverse=True) ans = a[0] cnt = 0 j = 1 for i in range(2, n): if cnt < 2: ans += a[i-j-cnt] cnt += 1 if cnt == 2: cnt = 0 j += 1 print(ans)
[["+", 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, 662, 12, 612], ["-", 0, 7, 8, 196, 0, 1, 0, 662, 31, 22], ["-", 0, 7, 8, 196, 0, 1, 0, 662, 0, 32], ["-", 0, 7, 8, 196, 0, 1, 0, 662, 12, 612]]
5
88
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int i; int n; long long sum; cin >> n; vector<long long> v(n); for (i = 0; i < n; ++i) { cin >> v[i]; } sort(v.begin(), v.end()); sum = v[0]; double k = 1; for (i = 1; i < n; i++) { sum += v[(int...
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int i; int n; long long sum; cin >> n; vector<long long> v(n); for (i = 0; i < n; i++) { cin >> v[i]; } sort(v.rbegin(), v.rend()); sum = v[0]; double k = 1; for (i = 2; i < n; i++) { sum += v[(i...
[["-", 0, 14, 8, 9, 0, 7, 26, 27, 17, 29], ["+", 0, 14, 8, 9, 0, 7, 26, 27, 17, 29], ["-", 0, 2, 3, 4, 0, 2, 63, 118, 119, 120], ["+", 0, 2, 3, 4, 0, 2, 63, 118, 119, 120], ["-", 0, 14, 8, 9, 0, 7, 10, 11, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 10, 11, 12, 13]]
1
122
import heapq N = int(input()) An = [int(e) for e in input().split()] def quick_sort(arr): left = [] right = [] if len(arr) <= 1: return arr ref = sum([e for e in arr]) / len(arr) for e in arr: if e < ref: left.append(e) else: right.append(e) i...
import heapq N = int(input()) An = [int(e) for e in input().split()] def quick_sort(arr): left = [] right = [] if len(arr) <= 1: return arr ref = sum([e for e in arr]) / len(arr) for e in arr: if e < ref: left.append(e) else: right.append(e) i...
[["+", 0, 1, 0, 662, 12, 634, 0, 664, 17, 33], ["+", 0, 1, 0, 652, 3, 4, 0, 664, 17, 33], ["-", 0, 52, 8, 196, 0, 1, 0, 677, 17, 107], ["+", 0, 52, 8, 196, 0, 1, 0, 677, 17, 110]]
5
187
n=int(input()) a=list(map(int,input().split())) a.sort(reverse=True) print( sum( a[(i+1)//2] for i in range(n)) )
n=int(input()) a=list(map(int,input().split())) a.sort(reverse=True) print( sum( a[i//2] for i in range(1,n)) )
[["-", 3, 668, 8, 206, 206, 657, 31, 23, 0, 24], ["-", 8, 206, 206, 657, 31, 23, 0, 657, 17, 72], ["-", 8, 206, 206, 657, 31, 23, 0, 657, 12, 612], ["-", 3, 668, 8, 206, 206, 657, 31, 23, 0, 25], ["+", 3, 668, 0, 659, 12, 652, 3, 4, 0, 612], ["+", 3, 668, 0, 659, 12, 652, 3, 4, 0, 21]]
5
56
n=int(input()) a=list(map(int,input().split())) a.sort(reverse=True) print( sum( a[(i+1)//2] for i in range(n)) )
n=int(input()) a=list(map(int,input().split())) a.sort(reverse=True) print( sum( a[(i+1)//2] for i in range(n-1)) )
[["+", 0, 659, 12, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 659, 12, 652, 3, 4, 0, 657, 12, 612]]
5
56
#include <bits/stdc++.h> using namespace std; int main(void) { int n; cin >> n; vector<int> v(n); for (int i = 0; i < n; i++) cin >> v[i]; sort(v.begin(), v.end()); long long ans = (n > 1) ? v[0] : 0; for (int i = 2, k = 1; i < n; i++) { ans += v[k]; if (i % 2) k++; } cout << ans...
#include <bits/stdc++.h> using namespace std; int main(void) { int n; cin >> n; vector<int> v(n); for (int i = 0; i < n; i++) cin >> v[i]; sort(v.rbegin(), v.rend()); long long ans = (n > 1) ? v[0] : 0; for (int i = 2, k = 1; i < n; i++) { ans += v[k]; if (i % 2) k++; } cout << ...
[["-", 0, 2, 3, 4, 0, 2, 63, 118, 119, 120], ["+", 0, 2, 3, 4, 0, 2, 63, 118, 119, 120]]
1
125
import sys import math import itertools import bisect from copy import copy from collections import deque,Counter from decimal import Decimal import functools def s(): return input() def k(): return int(input()) def S(): return input().split() def I(): return map(int,input().split()) def X(): return list(input()) def L...
import sys import math import itertools import bisect from copy import copy from collections import deque,Counter from decimal import Decimal import functools def s(): return input() def k(): return int(input()) def S(): return input().split() def I(): return map(int,input().split()) def X(): return list(input()) def L...
[["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 21]]
5
213
N = int(input()) A = [int(hoge) for hoge in input().split()] A.sort(reverse=True) Twoused = (N - 1)//2 Twosum = 2*sum([A[i] for i in range(1,Twoused+1)]) if N%2: ans = Twosum + A[0] + A[Twoused+1] else: ans = Twosum + A[0] print(ans)
N = int(input()) A = [int(hoge) for hoge in input().split()] A.sort(reverse=True) Twoused = (N - 2)//2 Twosum = 2*sum([A[i] for i in range(1,Twoused+1)]) if N%2: ans = Twosum + A[0] + A[Twoused+1] else: ans = Twosum + A[0] print(ans)
[["-", 0, 662, 12, 657, 31, 23, 0, 657, 12, 612], ["+", 0, 662, 12, 657, 31, 23, 0, 657, 12, 612]]
5
101