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 <iostream> #include <queue> #include <vector> using namespace std; int main() { long long N; cin >> N; vector<long long> A(N); for (long long i = 0; i < N; i++) cin >> A[i]; sort(A.begin(), A.end()); long long cnt = 0; priority_queue<long long> q; for (long long i = 0;...
#include <algorithm> #include <iostream> #include <queue> #include <vector> using namespace std; int main() { long long N; cin >> N; vector<long long> A(N); for (long long i = 0; i < N; i++) cin >> A[i]; sort(A.begin(), A.end()); long long cnt = 0; priority_queue<long long> q; for (long long i = 0;...
[["-", 8, 9, 0, 7, 8, 9, 0, 57, 0, 121], ["-", 0, 7, 8, 9, 0, 57, 15, 339, 0, 24], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["-", 0, 7, 8, 9, 0, 57, 15, 339, 0, 25]]
1
243
#include <bits/stdc++.h> #define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++) #define all(v) v.begin(), v.end() using ll = long long; using namespace std; int main() { int n; cin >> n; vector<int> a(n); ll ans = 0; rep(i, n) { cin >> a[i]; // a[i]=1000000000; } sort(all(a)); if (n % 2 =...
#include <bits/stdc++.h> #define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++) #define all(v) v.begin(), v.end() using ll = long long; using namespace std; int main() { int n; cin >> n; vector<int> a(n); ll ans = 0; rep(i, n) { cin >> a[i]; } sort(all(a)); if (n % 2 == 1) ans -= a[n / 2]; fo...
[["-", 0, 11, 12, 69, 341, 342, 0, 16, 17, 109], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 17, 85]]
1
132
#include <algorithm> #include <bitset> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stdint.h> #include <string> #include <vector> using namespace std; #define PI (3.14159265358979323846) #define INF (2147483647) #define INF_LL (9223372036854775807) ...
#include <algorithm> #include <bitset> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stdint.h> #include <string> #include <vector> using namespace std; #define PI (3.14159265358979323846) #define INF (2147483647) #define INF_LL (9223372036854775807) ...
[["-", 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
231
#include <bits/stdc++.h> using namespace std; #define inf 1000000000 #define unvisited -1 #define visited 1 #define eps 1e-9 #define mp make_pair #define pb push_back #define pi acos(-1.0) #define uint64 unsigned long long #define FastSlowInput \ ios_base::syn...
#include <bits/stdc++.h> using namespace std; #define inf 1000000000 #define unvisited -1 #define visited 1 #define eps 1e-9 #define mp make_pair #define pb push_back #define pi acos(-1.0) #define uint64 unsigned long long #define FastSlowInput \ ios_base::syn...
[["+", 8, 9, 0, 57, 64, 9, 0, 93, 0, 94], ["+", 8, 9, 0, 57, 64, 9, 0, 93, 0, 35], ["+", 0, 57, 75, 76, 0, 9, 0, 1, 0, 35], ["+", 75, 76, 0, 9, 0, 1, 0, 27, 28, 22], ["+", 75, 76, 0, 9, 0, 1, 0, 27, 17, 68]]
1
290
#include <algorithm> #include <bitset> #include <cctype> #include <cerrno> #include <clocale> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <cwchar> #include <cwctype> #include <deque> #include <exception> #include <fstream> #include <functional> #...
#include <algorithm> #include <bitset> #include <cctype> #include <cerrno> #include <clocale> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <cwchar> #include <cwctype> #include <deque> #include <exception> #include <fstream> #include <functional> #...
[["+", 8, 9, 0, 1, 0, 2, 63, 118, 119, 120], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["+", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35], ["+", 8, 9, 0, 1, 0, 2, 63, 118, 28, 22], ["+", 8, 9, 0, 1, 0, 2, 63, 118, 17, 131]]
1
253
import sys def resolve(): inp = sys.stdin.readlines() inp = list(map(lambda x: x.strip(), inp)) N = int(inp[0]) A = list(map(int, inp[1].split(' '))) A.sort(reverse=True) num = 0 for i in range(N-1): num += A[i+1//2] print(num) resolve()
import sys def resolve(): inp = sys.stdin.readlines() inp = list(map(lambda x: x.strip(), inp)) N = int(inp[0]) A = list(map(int, inp[1].split(' '))) A.sort(reverse=True) num = 0 for i in range(N-1): num += A[(i+1)//2] print(num) resolve()
[["+", 0, 677, 12, 206, 206, 657, 31, 23, 0, 24], ["+", 0, 677, 12, 206, 206, 657, 31, 23, 0, 25]]
5
102
import java.util.*; import java.util.Comparator; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); Integer[] a = new Integer[N]; for (int i = 0; i < N; i++) { a[i] = sc.nextInt(); } Arrays.sort(a, Comparator.reverseOrd...
import java.util.*; import java.util.Comparator; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); Integer[] a = new Integer[N]; for (int i = 0; i < N; i++) { a[i] = sc.nextInt(); } Arrays.sort(a, Comparator.reverseOrd...
[["+", 0, 11, 12, 74, 51, 504, 71, 16, 17, 72], ["+", 0, 11, 12, 74, 51, 504, 71, 16, 12, 499]]
3
211
n = int(input()) a = list(map(int,input().split())) a.sort(reverse = True) ans = 0 ans += a[0] i = 1 j = 1 while i < n-1 : if i+2 < n-1 : ans += 2*a[j] j += 1 i += 2 else : ans += a[j] j += 1 i += 1 print(ans)
n = int(input()) a = list(map(int,input().split())) a.sort(reverse = True) ans = 0 ans += a[0] i = 1 j = 1 while i < n-1 : if i+2 <= n-1 : ans += 2*a[j] j += 1 i += 2 else : ans += a[j] j += 1 i += 1 print(ans)
[["-", 0, 52, 8, 196, 0, 57, 15, 666, 667, 18], ["+", 0, 52, 8, 196, 0, 57, 15, 666, 667, 19]]
5
96
#include <bits/stdc++.h> using namespace std; int main() { long long N, i, Sum = 0; cin >> N; vector<long long> A(N); queue<long long> nxt; for (i = 0; i < N; i++) cin >> A[i]; sort(A.begin(), A.end()); reverse(A.begin(), A.end()); nxt.push(A[0]); for (i = 1; i < N; i++) { nxt.push(A[1]); ...
#include <bits/stdc++.h> using namespace std; int main() { long long N, i, Sum = 0; cin >> N; vector<long long> A(N); queue<long long> nxt; for (i = 0; i < N; i++) cin >> A[i]; sort(A.begin(), A.end()); reverse(A.begin(), A.end()); nxt.push(A[0]); for (i = 1; i < N; i++) { nxt.push(A[i]); ...
[["-", 0, 2, 3, 4, 0, 69, 341, 342, 0, 13], ["+", 0, 2, 3, 4, 0, 69, 341, 342, 0, 22]]
1
161
num = (int)(input()) a = sorted(list(map(int, input().split(" "))), reverse=True) b = [a[0]] total = a[0] for i in range(3, num): total += a[(i - 1) // 2] print(total)
num = (int)(input()) a = sorted(list(map(int, input().split(" "))), reverse=True) b = [a[0]] total = a[0] for i in range(3, num + 1): total += a[(i - 1) // 2] print(total)
[["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
77
n = int(input()) A = list(map(int,input().split())) A.sort(reverse=True) ans = A[0] for i in range(1,n-1): ans += A[(i//2) + 1] print(ans)
n = int(input()) A = list(map(int,input().split())) A.sort(reverse=True) ans = A[0] for i in range(n-2): ans += A[(i//2) + 1] print(ans)
[["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612], ["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 21], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
67
#include <iostream> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <string> using namespace std; int compare_long(const void *a, const void *b) { return *(long long *)b - *(long long *)a; } int main() { long long N; cin >> N; // f(x); long long confort[200001]; long long sum = 0; ...
#include <iostream> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <string> using namespace std; int compare_long(const void *a, const void *b) { return *(long long *)b - *(long long *)a; } int main() { long long N; cin >> N; // f(x); long long confort[200001]; long long sum = 0;...
[["-", 0, 11, 12, 69, 341, 342, 0, 16, 17, 33], ["-", 0, 11, 12, 69, 341, 342, 0, 16, 12, 13]]
1
184
N=int(input()) A=list(map(int,input().split())) A.sort(reverse=True) ans=A[0] if N%2==0: mat=N//2 for i in range(mat-1): ans+=2*A[1+i] else: mat=(N-1)//2 for j in range(mat-1): ans+=2*A[1+j] ans+=A[mat-1] print(ans)
N=int(input()) A=list(map(int,input().split())) A.sort(reverse=True) ans=A[0] if N%2==0: mat=N//2 for i in range(mat-1): ans+=2*A[1+i] else: mat=(N-1)//2 for j in range(mat-1): ans+=2*A[1+j] ans+=A[mat] print(ans)
[["-", 0, 1, 0, 677, 12, 206, 206, 657, 17, 33], ["-", 0, 1, 0, 677, 12, 206, 206, 657, 12, 612]]
5
114
/* Coded and Decoded by : Yash Kapoor */ #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; using namespace std; // s.find_by_order(index); // s.order_of_key(value); #define ll long long #define ld long double #define pb push_back #define pf push_front #define mp make_pair...
/* Coded and Decoded by : Yash Kapoor */ #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; using namespace std; // s.find_by_order(index); // s.order_of_key(value); #define ll long long #define ld long double #define pb push_back #define pf push_front #define mp make_pair...
[["+", 0, 11, 12, 69, 341, 342, 0, 16, 17, 33], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 12, 13]]
1
366
# -*- coding: utf-8 -*- ############# # Libraries # ############# import sys input = sys.stdin.readline import math #from math import gcd import bisect import heapq from collections import defaultdict from collections import deque from collections import Counter from functools import lru_cache ############# # Const...
# -*- coding: utf-8 -*- ############# # Libraries # ############# import sys input = sys.stdin.readline import math #from math import gcd import bisect import heapq from collections import defaultdict from collections import deque from collections import Counter from functools import lru_cache ############# # Const...
[["+", 0, 1, 0, 662, 12, 634, 0, 664, 17, 33], ["-", 0, 7, 8, 196, 0, 1, 0, 677, 17, 107], ["+", 0, 7, 8, 196, 0, 1, 0, 677, 17, 110], ["+", 0, 1, 0, 652, 3, 4, 0, 664, 17, 33]]
5
1,114
<?php $N = (int)fgets(STDIN); $A = array_map(function ($n) { return (int)$n; }, explode(' ', fgets(STDIN))); rsort($A); if ($N % 2 === 0) { echo array_sum(array_slice($A, 0, $N / 2)) * 2 - $A[0]; return; } echo array_sum(array_slice($A, 0, $N / 2)) * 2 - $A[0] + $A[($N + 1) / 2];
<?php $N = (int)fgets(STDIN); $A = array_map(function ($n) { return (int)$n; }, explode(' ', fgets(STDIN))); rsort($A); if ($N % 2 === 0) { echo array_sum(array_slice($A, 0, $N / 2)) * 2 - $A[0]; return; } echo array_sum(array_slice($A, 0, ($N - 1) / 2)) * 2 - $A[0] + $A[($N - 1) / 2];
[["+", 3, 3, 0, 28, 0, 16, 31, 23, 0, 24], ["+", 0, 28, 0, 16, 31, 23, 0, 16, 17, 33], ["+", 0, 28, 0, 16, 31, 23, 0, 16, 12, 612], ["+", 3, 3, 0, 28, 0, 16, 31, 23, 0, 25], ["-", 12, 69, 0, 16, 31, 23, 0, 16, 17, 72], ["+", 12, 69, 0, 16, 31, 23, 0, 16, 17, 33]]
6
127
n=int(input()) a=list(map(int,input().split())) a.sort() a.reverse() if n%2==0: s=0 s=2*(sum(a[0:(n//2)]))-a[0] print(s) else: s=0 s=2*(sum(a[0:(n//2)+1]))-a[0]-a[(n+1)//2] print(s)
n=int(input()) a=list(map(int,input().split())) a.sort() a.reverse() if n%2==0: s=0 s=2*(sum(a[0:(n//2)]))-a[0] print(s) else: s=0 s=2*(sum(a[0:(n//2)+1]))-a[0]-a[n//2] print(s)
[["-", 12, 657, 12, 206, 206, 657, 31, 23, 0, 24], ["-", 12, 206, 206, 657, 31, 23, 0, 657, 17, 72], ["-", 12, 206, 206, 657, 31, 23, 0, 657, 12, 612], ["-", 12, 657, 12, 206, 206, 657, 31, 23, 0, 25]]
5
119
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define INF 1e9; using namespace std; using ll = long long; 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()); reverse(A.begin(), A.end()); int ans = A[0]...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define INF 1e9; using namespace std; using ll = long long; 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()); reverse(A.begin(), A.end()); ll ans = A[0];...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["-", 0, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["-", 0, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
1
212
import collections N = int(input()) As = list(map(int, input().split())) As.sort(reverse = True) print(As) circle_que = collections.deque() circle_que.append(As[0]) ans = 0 for A in As[1:]: circle_que.append(A) circle_que.append(A) ans += circle_que.popleft() #print(ans) print(ans)
import collections N = int(input()) As = list(map(int, input().split())) As.sort(reverse = True) #print(As) circle_que = collections.deque() circle_que.append(As[0]) ans = 0 for A in As[1:]: circle_que.append(A) circle_que.append(A) ans += circle_que.popleft() #print(ans) print(ans)
[["-", 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
91
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll INF = 1e18; const ll mod = 1e9 + 7; #define rep(i, n) for (int i = 0; i < n; i++) int main() { int n; cin >> n; std::vector<ll> a(n); rep(i, n) cin >> a[i]; sort(a.begin(), a.end(), greater<ll>()); int times = 1; int head = 0; ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll INF = 1e18; const ll mod = 1e9 + 7; #define rep(i, n) for (int i = 0; i < n; i++) int main() { int n; cin >> n; std::vector<ll> a(n); rep(i, n) cin >> a[i]; sort(a.begin(), a.end(), greater<ll>()); int times = 1; int head = 0; ...
[["+", 75, 76, 0, 9, 0, 1, 0, 27, 28, 22], ["+", 75, 76, 0, 9, 0, 1, 0, 27, 17, 29], ["+", 0, 57, 75, 76, 0, 9, 0, 1, 0, 35]]
1
160
/*COMPETITIVE PROGRAMMING C++ TEMPLATE */ #include <algorithm> #include <climits> #include <cmath> #include <iomanip> #include <iostream> #include <iterator> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> #define al...
/*COMPETITIVE PROGRAMMING C++ TEMPLATE */ #include <algorithm> #include <climits> #include <cmath> #include <iomanip> #include <iostream> #include <iterator> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> #define al...
[["+", 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
231
N = gets.to_i A = gets.chomp.split.map(&:to_i).sort.reverse ans = A[0] (1..(N-2)/2).each do |i| ans += A[i]*2 if (N-2)%2 == 1 ans += A[(N-2)/2+1] end end puts ans
N = gets.to_i A = gets.chomp.split.map(&:to_i).sort.reverse ans = A[0] (1..(N-2)/2).each do |i| ans += A[i]*2 end if (N-2)%2 == 1 ans += A[(N-2)/2+1] end puts ans
[["+", 36, 36, 0, 493, 0, 652, 196, 737, 0, 444], ["-", 0, 652, 196, 737, 8, 736, 0, 121, 0, 444]]
4
81
#include <algorithm> #include <bitset> #include <cassert> #include <climits> #include <cmath> #include <cstdio> #include <cstring> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include...
#include <algorithm> #include <bitset> #include <cassert> #include <climits> #include <cmath> #include <cstdio> #include <cstring> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include...
[["+", 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
240
n=int(input()) a=list(map(int,input().split())) sorted=sorted(a,reverse=True) #print(len(sorted[2:])//2) ans=sorted[0] for i in range(1,len(sorted[2:])//2 + 1): ans+=sorted[1+i]*2 #print(sorted[1+i]) if len(a)%2==1: ans+=sorted[2 + len(sorted[2:])//2] print(ans)
n=int(input()) a=list(map(int,input().split())) sorted=sorted(a,reverse=True) #print(len(sorted[2:])//2) ans=sorted[0] for i in range(len(sorted[2:])//2): ans+=sorted[1+i]*2 #print(ans) if len(a)%2==1: ans+=sorted[1 + len(sorted[2:])//2] #print(111) print(ans)
[["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612], ["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 21], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612], ["-", 0, 1, 0, 677, 12, 206, 206, 657, 31, 612], ["+", 0, 1, 0, 677, 12, 206, 206, 657, 31, 612]]
5
105
#include <bits/stdc++.h> using namespace std; int main() { long N; cin >> N; vector<long> a(N); for (int i = 0; i < N; i++) cin >> a[i]; sort(a.begin(), a.end()); reverse(a.begin(), a.end()); long ans = 0; for (int i = 0; i < N - 1; i++) { ans += a[i]; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { long N; cin >> N; vector<long> a(N); for (int i = 0; i < N; i++) cin >> a[i]; sort(a.begin(), a.end()); reverse(a.begin(), a.end()); long ans = 0; for (int i = 0; i < N - 1; i++) { ans += a[(i + 1) / 2]; } cout << ans << endl; }
[["+", 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], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 17, 85], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 12, 13]]
1
115
#!/usr/bin/env python3 from collections import defaultdict,deque from heapq import heappush, heappop from bisect import bisect_left, bisect_right import sys, random, itertools, math sys.setrecursionlimit(10**5) input = sys.stdin.readline sqrt = math.sqrt def LI(): return list(map(int, input().split())) def LF(): return...
#!/usr/bin/env python3 from collections import defaultdict,deque from heapq import heappush, heappop from bisect import bisect_left, bisect_right import sys, random, itertools, math sys.setrecursionlimit(10**5) input = sys.stdin.readline sqrt = math.sqrt def LI(): return list(map(int, input().split())) def LF(): return...
[["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 21], ["-", 0, 677, 12, 206, 206, 657, 31, 23, 0, 24], ["-", 12, 206, 206, 657, 31, 23, 0, 657, 17, 72], ["-", 12, 206, 206, 657, 31, 23, 0, 657, 12, 612], ["-", 0, 677, 12, 206, 206, 657, 31, 23, 0, 25]]
5
381
///*Bismillahir Rahmanir Rahim***/// /***Stay_Home_Stay_Safe***/ ///**Author Thasin Sheikh**/// #include <bits/stdc++.h> using namespace std; #define MAX 1e6 + 10 #define MOD 1000000007 #define PI 3.14159265359 #define makefast__ ios_base::sync_with_stdio(false); using ll = long long int; using dl = double; const int N...
///*Bismillahir Rahmanir Rahim***/// /***Stay_Home_Stay_Safe***/ ///**Author Thasin Sheikh**/// #include <bits/stdc++.h> using namespace std; #define MAX 1e6 + 10 #define MOD 1000000007 #define PI 3.14159265359 #define makefast__ ios_base::sync_with_stdio(false); using ll = long long int; using dl = double; const int N...
[["-", 8, 9, 0, 1, 0, 11, 12, 69, 28, 22], ["+", 8, 9, 0, 1, 0, 11, 12, 69, 28, 22]]
1
252
#include "bits/stdc++.h" #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define REP(i, n) for (int i = 1; i <= (int)(n); i++) #define all(v) v.begin(), v.end() using namespace std; using ll = long long; using pi = pair<int, int>; const ll INF = 1LL << 60; int main() { ll n, a, ans = 0; cin >> n; vector<ll...
#include "bits/stdc++.h" #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define REP(i, n) for (int i = 1; i <= (int)(n); i++) #define all(v) v.begin(), v.end() using namespace std; using ll = long long; using pi = pair<int, int>; const ll INF = 1LL << 60; int main() { ll n, a, ans = 0; cin >> n; vector<ll...
[["-", 0, 11, 12, 16, 31, 23, 0, 16, 12, 13], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 12, 13], ["-", 0, 11, 12, 69, 341, 342, 0, 16, 12, 13], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 12, 13]]
1
191
#include <bits/stdc++.h> using namespace std; int main() { long long n, ans = 0; 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()); for (long long i = 0; i < n / 2; i++) { ans += vec.at(i) * ...
#include <bits/stdc++.h> using namespace std; int main() { long long n, ans = 0; 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()); for (long long i = 0; i < n / 2; i++) { ans += vec.at(i) * ...
[["-", 0, 11, 12, 2, 3, 4, 0, 16, 17, 72], ["-", 0, 11, 12, 2, 3, 4, 0, 16, 12, 13]]
1
158
#include <bits/stdc++.h> using namespace std; // typedef // ----------------------------------------------------------------------------- typedef long long ll; typedef long double ld; // container util // ----------------------------------------------------------------------------- #define ALL(c) (c).begin(), (c).end...
#include <bits/stdc++.h> using namespace std; // typedef // ----------------------------------------------------------------------------- typedef long long ll; typedef long double ld; // container util // ----------------------------------------------------------------------------- #define ALL(c) (c).begin(), (c).end...
[["-", 8, 9, 0, 43, 49, 50, 51, 69, 28, 22], ["-", 0, 43, 49, 50, 51, 69, 341, 342, 0, 70], ["-", 0, 43, 49, 50, 51, 69, 341, 342, 0, 73]]
1
219
#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() { ll n; cin >> n; vector<ll> A(n); rep(i, n) cin >> A[i]; sort(A.begin(), A.end()); ll ans = 0; rep(i, n - 1) ans += A[n - 1 - (i + 1) % 2]; 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() { ll n; cin >> n; vector<ll> A(n); rep(i, n) cin >> A[i]; sort(A.begin(), A.end()); ll ans = 0; rep(i, n - 1) ans += A[n - 1 - (i + 1) / 2]; cout <...
[["-", 12, 69, 341, 342, 0, 16, 12, 16, 17, 109], ["+", 12, 69, 341, 342, 0, 16, 12, 16, 17, 85]]
1
120
import math n = int(input()) a = list(map(int, input().split())) a.sort(reverse=True) ans = a[0] for i in range(2, n): ans += a[math.ceil(i / 2)] print(ans)
import math n = int(input()) a = list(map(int, input().split())) a.sort(reverse=True) ans = a[0] for i in range(1, n - 1): ans += a[math.ceil(i / 2)] print(ans)
[["-", 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
68
#include <bits/stdc++.h> using namespace std; main() { int n; cin >> n; vector<int> a(n); for (int &x : a) cin >> x; long long ans = *max_element(begin(a), end(a)); a.erase(max_element(begin(a), end(a))); nth_element(begin(a), begin(a) + (n - 2) / 2, end(a), greater<int>()); nth_element(begin(a) +...
#include <bits/stdc++.h> using namespace std; main() { int n; cin >> n; vector<int> a(n); for (int &x : a) cin >> x; long long ans = *max_element(begin(a), end(a)); a.erase(max_element(begin(a), end(a))); nth_element(begin(a), begin(a) + (n - 2) / 2, end(a), greater<int>()); nth_element(begin(a) +...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
214
/***** author : C0d1ngPhenomena *****/ #include <bits/stdc++.h> #define endl "\n" #define ll long long int #define TestCases \ int T; \ cin >> T; ...
/***** author : C0d1ngPhenomena *****/ #include <bits/stdc++.h> #define endl "\n" #define ll long long int #define TestCases \ int T; \ cin >> T; ...
[["+", 0, 11, 12, 69, 341, 342, 0, 16, 17, 85], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 12, 13]]
1
178
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; int main() { int64_t n, sum = 0; cin >> n; vector<int64_t> a(n); rep(i, n) cin >> a.at(i); sort(a.begin(), a.end()); // cout << a.at(0) << endl; sum += a.at(n - 1); if (n % 2 == 0) { int x = (n - 1) / ...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; int main() { int64_t n, sum = 0; cin >> n; vector<int64_t> a(n); rep(i, n) cin >> a.at(i); sort(a.begin(), a.end()); // cout << a.at(0) << endl; sum += a.at(n - 1); if (n % 2 == 0) { int x = (n - 1) / ...
[["-", 12, 2, 3, 4, 0, 16, 31, 16, 12, 22], ["-", 0, 11, 12, 2, 3, 4, 0, 16, 17, 33], ["+", 3, 4, 0, 16, 31, 16, 12, 16, 31, 22], ["+", 3, 4, 0, 16, 31, 16, 12, 16, 17, 85], ["+", 0, 11, 12, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 11, 12, 2, 3, 4, 0, 16, 12, 13]]
1
206
n = int(input()) a = list(map(int, input().split())) a.sort() ans = 0 for i in range(1, n): ans += a[n-int(i/2)] print(ans)
n = int(input()) a = list(map(int, input().split())) a.sort() ans = 0 for i in range(1, n): ans += a[n-int(i/2)-1] print(ans)
[["+", 0, 1, 0, 677, 12, 206, 206, 657, 17, 33], ["+", 0, 1, 0, 677, 12, 206, 206, 657, 12, 612]]
5
60
#include <bits/stdc++.h> #define rep(i, a, b) for (int i = a; i < (b); i++) #define rrep(i, a, b) for (int i = a; i >= (b); i--) #define all(x) (x).begin(), (x).end() using namespace std; using ll = long long; using P = pair<int, int>; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; retu...
#include <bits/stdc++.h> #define rep(i, a, b) for (int i = a; i < (b); i++) #define rrep(i, a, b) for (int i = a; i >= (b); i--) #define all(x) (x).begin(), (x).end() using namespace std; using ll = long long; using P = pair<int, int>; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; retu...
[["-", 0, 1, 0, 11, 12, 69, 341, 342, 0, 13], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 31, 22], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 17, 85], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 12, 13]]
1
259
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) #define INF 1000000007 using namespace std; int main() { int n; cin >> n; long a[n]; rep(i, n) cin >> a[i]; sort(a, a + n); long ans = 0; rep(i, n) { ans += a[n - 1 - (i + 1) / 2]; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) #define INF 1000000007 using namespace std; int main() { int n; cin >> n; long a[n]; rep(i, n) cin >> a[i]; sort(a, a + n); long ans = 0; rep(i, n - 1) { ans += a[n - 1 - (i + 1) / 2]; } cout << ans << endl; return 0; }
[["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 25, 0, 35]]
1
98
package main import ( "bufio" "fmt" "os" "sort" "strconv" ) func main() { N := nextInt() A := make(conf, N) for i := 0; i < N; i++ { A[i] = nextInt64() } sort.Sort(A) ans := int64(0) for i := 0; i < N-1; i++ { ans += A[i] } fmt.Println(ans) } type conf []int64 func (a conf) Len() int ...
package main import ( "bufio" "fmt" "os" "sort" "strconv" ) func main() { N := nextInt() A := make(conf, N) for i := 0; i < N; i++ { A[i] = nextInt64() } sort.Sort(A) ans := int64(0) for i := 0; i < N-1; i++ { ans += A[(i+1)/2] } fmt.Println(ans) } type conf []int64 func (a conf) Len() int ...
[["+", 12, 432, 0, 437, 71, 16, 31, 23, 0, 24], ["+", 0, 437, 71, 16, 31, 23, 0, 16, 17, 72], ["+", 0, 437, 71, 16, 31, 23, 0, 16, 12, 433], ["+", 12, 432, 0, 437, 71, 16, 31, 23, 0, 25], ["+", 0, 436, 12, 432, 0, 437, 71, 16, 17, 85], ["+", 0, 436, 12, 432, 0, 437, 71, 16, 12, 433]]
7
385
import collections def resolve(): N = int(input()) A = [int(x) for x in input().split(" ")] setA = set(A) listA = list(setA) collectionA = collections.Counter(A) result = listA[-1] collectionA[listA[-1]] -= 1 if collectionA[listA[-1]] == 0: listA.pop() for list_a in listA: collectionA[list...
import collections def resolve(): N = int(input()) A = [int(x) for x in input().split(" ")] setA = set(A) listA = sorted(list(setA)) collectionA = collections.Counter(A) result = listA[-1] collectionA[listA[-1]] -= 1 if collectionA[listA[-1]] == 0: listA.pop() for list_a in listA: collecti...
[["+", 8, 196, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
159
#include <stdio.h> #include <stdlib.h> long long int compare(long long int x, long long int y) { return y - x; } int main() { int i; int N; long long int result; long long int *arr; scanf("%d\n", &N); arr = (long long int *)malloc(sizeof(long long int) * N); for (i = 0; i < N; i++) { scanf("%lld", &...
#include <stdio.h> #include <stdlib.h> int compare(long long int *x, long long int *y) { return *y - *x; } int main() { int i; int N; long long int result; long long int *arr; scanf("%d\n", &N); arr = (long long int *)malloc(sizeof(long long int) * N); for (i = 0; i < N; i++) { scanf("%lld", &(arr[i...
[["-", 36, 36, 0, 30, 0, 14, 39, 86, 0, 96], ["+", 49, 53, 54, 55, 0, 56, 49, 84, 0, 48], ["+", 8, 9, 0, 37, 0, 16, 31, 66, 17, 48], ["+", 8, 9, 0, 37, 0, 16, 12, 66, 17, 48]]
0
178
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll mod = 998244353; ll mul(ll a, ll b) { return ((a % mod) * (b % mod)) % mod; } ll power(ll a, ll b) { ll z = 1; ll x = a; while (b > 0) { if (b & 1) z = mul(z, x); x = mul(x, x); b >>= 1; } return z; } int main() { ll n;...
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll mod = 998244353; ll mul(ll a, ll b) { return ((a % mod) * (b % mod)) % mod; } ll power(ll a, ll b) { ll z = 1; ll x = a; while (b > 0) { if (b & 1) z = mul(z, x); x = mul(x, x); b >>= 1; } return z; } int main() { ll n;...
[["-", 0, 14, 8, 9, 0, 1, 0, 27, 17, 29], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 17, 107], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13]]
1
294
#include <bits/stdc++.h> using namespace std; #define froop1(a, n) for (int i = a; i < n; i++) #define froop2(a, n) for (int i = a; i > n; i--) #define ll long long #define pq(name, type) priority_queue<type> name #define vec(name, type, length, value) vector<type> name(length, value) #define vec2(name, type, length...
#include <bits/stdc++.h> using namespace std; #define froop1(a, n) for (int i = a; i < n; i++) #define froop2(a, n) for (int i = a; i > n; i--) #define ll long long #define pq(name, type) priority_queue<type> name #define vec(name, type, length, value) vector<type> name(length, value) #define vec2(name, type, length...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
208
import java.io.BufferedWriter; import java.io.File; import java.io.IOException; import java.io.OutputStreamWriter; import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) throws IOException { Scanner scanner = new Scanner(System.in); int cases = scanner.n...
import java.io.BufferedWriter; import java.io.File; import java.io.IOException; import java.io.OutputStreamWriter; import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) throws IOException { Scanner scanner = new Scanner(System.in); int cases = scanner.n...
[["-", 8, 196, 0, 57, 15, 15, 0, 16, 12, 499], ["+", 8, 196, 0, 57, 15, 15, 0, 16, 12, 499], ["-", 0, 57, 64, 1, 0, 11, 12, 16, 31, 499], ["-", 0, 57, 64, 1, 0, 11, 12, 16, 17, 48], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 95]]
3
221
/****** AUTHOR : RUDRANSH TRIPATHI, IIIT NAGPUR, CCID(rt24) & CFID(rsgt24) MOTTO : Use criticism as fuel and you will never run out of energy. AIM : TO BECOME A BETTER CODER INTROSPECT + COURSE CORRECTIONS = CATALYST FOR SUCCESS Every moment is an opportunity to better yourself *******/ #inc...
/****** AUTHOR : RUDRANSH TRIPATHI, IIIT NAGPUR, CCID(rt24) & CFID(rsgt24) MOTTO : Use criticism as fuel and you will never run out of energy. AIM : TO BECOME A BETTER CODER INTROSPECT + COURSE CORRECTIONS = CATALYST FOR SUCCESS Every moment is an opportunity to better yourself *******/ #inc...
[["-", 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
172
import heapq n = int(input()) a_lst = list(map(int, input().split(" "))) a_lst.sort(reverse=True) result = 0 heap = [] heapq.heappush(heap,a_lst[0]) for i in a_lst[1:]: now_max = heapq.heappop(heap) result += now_max heapq.heappush(heap, i) heapq.heappush(heap, i) print(result)
import heapq n = int(input()) a_lst = list(map(int, input().split(" "))) a_lst.sort(reverse=True) result = 0 heap = [] heapq.heappush(heap,-a_lst[0]) for i in a_lst[1:]: now_max = heapq.heappop(heap) result += now_max heapq.heappush(heap, -i) heapq.heappush(heap, -i) print(-result)
[["+", 0, 1, 0, 652, 3, 4, 0, 664, 17, 33]]
5
96
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < (n); ++i) #define REP2(i, x, n) for (int i = x; i < (n); ++i) #define ALL(v) v.begin(), v.end() #define RALL(v) v.rbegin(), v.rend() using namespace std; using ll = long long; using P = pair<int, int>; static const double PI = acos(-1); int main() { int ...
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < (n); ++i) #define REP2(i, x, n) for (int i = x; i < (n); ++i) #define ALL(v) v.begin(), v.end() #define RALL(v) v.rbegin(), v.rend() using namespace std; using ll = long long; using P = pair<int, int>; static const double PI = acos(-1); int main() { int ...
[["+", 8, 9, 0, 57, 75, 76, 0, 9, 0, 45], ["-", 12, 74, 51, 69, 341, 342, 0, 16, 17, 33], ["-", 12, 74, 51, 69, 341, 342, 0, 16, 12, 13], ["+", 8, 9, 0, 57, 75, 76, 0, 9, 0, 46]]
1
204
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using P = pair<int, int>; int n, ans; int main() { cin >> n; vector<int> a(n); rep(i, n) { cin >> a[i]; } sort(a.rbegin(), a.rend()); for (int i = 1; i <= n; i++) { ans += a[i / 2]; } ...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using P = pair<int, int>; ll n, ans; int main() { cin >> n; vector<int> a(n); rep(i, n) { cin >> a[i]; } sort(a.rbegin(), a.rend()); ans = 0; for (int i = 1; i < n; i++) { ans += a[i / 2...
[["-", 36, 36, 36, 36, 0, 30, 0, 43, 39, 40], ["+", 36, 36, 36, 36, 0, 30, 0, 43, 39, 78], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 14, 8, 9, 0, 7,...
1
118
N = int(input()) A = list(map(int, input().split())) A.sort() A.reverse() list = [] ans = 0 list.append(A[0]) for i in range(len(A)): ans += list[i] list.append(A[i]) list.append(A[i]) print(ans)
N = int(input()) A = list(map(int, input().split())) A.sort() A.reverse() list = [] ans = 0 list.append(A[0]) for i in range(1, len(A)): ans += list[i - 1] list.append(A[i]) list.append(A[i]) print(ans)
[["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 21], ["+", 0, 1, 0, 677, 12, 206, 206, 657, 17, 33], ["+", 0, 1, 0, 677, 12, 206, 206, 657, 12, 612]]
5
90
#include <bits/stdc++.h> #define _GLIBCXX_DEBUG #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++) using namespace std; typedef long long ll; ll A[300000]; ll X[5]; int main() { ll N; cin >> N; rep(i, N) cin >> A[i]; sort(A, A + N); reverse(A...
#include <bits/stdc++.h> #define _GLIBCXX_DEBUG #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++) using namespace std; typedef long long ll; ll A[300000]; ll X[5]; int main() { ll N; cin >> N; rep(i, N) cin >> A[i]; sort(A, A + N); reverse(A...
[["-", 0, 1, 0, 11, 12, 69, 341, 342, 0, 13], ["+", 0, 1, 0, 11, 12, 69, 341, 342, 0, 13]]
1
223
N=int(input()) l=sorted(list(map(int,input().split()))) l.reverse() s=l[0]-N%2*l[N//2] for i in range(N//2): s+=l[i+1]*2 print(s)
N=int(input()) l=sorted(list(map(int,input().split()))) l.reverse() s=l[0]+N%2*l[N//2] for i in range(N//2-1): s+=l[i+1]*2 print(s)
[["-", 0, 656, 0, 1, 0, 662, 12, 657, 17, 33], ["+", 0, 656, 0, 1, 0, 662, 12, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
74
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll n; cin >> n; vector<ll> a(n); for (ll i = 0; i < n; i++) { cin >> a.at(i); } sort(a.begin(), a.end()); reverse(a.begin(), a.end()); ll ans = 0; for (ll i = 1; i < n; i++) { ll j = (i + 1) / 2; ans += a.at(...
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll n; cin >> n; vector<ll> a(n); for (ll i = 0; i < n; i++) { cin >> a.at(i); } sort(a.begin(), a.end()); reverse(a.begin(), a.end()); ll ans = 0; for (ll i = 0; i < n - 1; i++) { ll j = (i + 1) / 2; ans += a...
[["-", 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]]
1
138
#include <bits/stdc++.h> // below comment for pbds #include <ext/pb_ds/assoc_container.hpp> // to use it make ordered_set #include <ext/pb_ds/tree_policy.hpp> // all set fnct + = 1. order_of_key(x); // number of #define ll long long // element strictly smaller than it; #define ld ...
#include <bits/stdc++.h> // below comment for pbds #include <ext/pb_ds/assoc_container.hpp> // to use it make ordered_set #include <ext/pb_ds/tree_policy.hpp> // all set fnct + = 1. order_of_key(x); // number of #define ll long long // element strictly smaller than it; #define ld ...
[["+", 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
235
package main import ( "bufio" "fmt" "os" "sort" "strconv" ) var lower, higher []int var heapSize int func main() { var n int fmt.Scan(&n) sc := bufio.NewScanner(os.Stdin) sc.Split(bufio.ScanWords) as := make([]int, n) for i := range as { sc.Scan() as[i], _ = strconv.Atoi(sc.Text()) } sort.Ints(as) ...
package main import ( "bufio" "fmt" "os" "sort" "strconv" ) var lower, higher []int var heapSize int func main() { var n int fmt.Scan(&n) sc := bufio.NewScanner(os.Stdin) sc.Split(bufio.ScanWords) as := make([]int, n) for i := range as { sc.Scan() as[i], _ = strconv.Atoi(sc.Text()) } sort.Ints(as) ...
[["-", 8, 196, 0, 57, 15, 16, 31, 16, 17, 19], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 18]]
7
555
n = int(input()) a = list(map(int, input().split(' '))) def merge_sort(arr): if len(arr) <= 1: return arr mid = len(arr) // 2 # ここで分割を行う left = arr[:mid] right = arr[mid:] # 再帰的に分割を行う left = merge_sort(left) right = merge_sort(right) # returnが返ってきたら、結合を行い、結合したものを次に渡す ...
n = int(input()) a = list(map(int, input().split(' '))) def merge_sort(arr): if len(arr) <= 1: return arr mid = len(arr) // 2 # ここで分割を行う left = arr[:mid] right = arr[mid:] # 再帰的に分割を行う left = merge_sort(left) right = merge_sort(right) # returnが返ってきたら、結合を行い、結合したものを次に渡す ...
[["-", 0, 1, 0, 677, 12, 206, 206, 657, 17, 72], ["-", 0, 1, 0, 677, 12, 206, 206, 657, 12, 612]]
5
253
n = int(input()) a = list(map(int, input().split())) b = sorted(a, reverse=True) ans = 0 for i in range(n): ans += b[(i+1)//2] print(ans)
n = int(input()) a = list(map(int, input().split())) b = sorted(a, reverse=True) ans = 0 for i in range(n-1): ans += b[(i+1)//2] print(ans)
[["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
62
#define rep(i, n) for (int i = 0; i < (int)(n); i++) #include <bits/stdc++.h> using namespace std; int main() { long long int N, res = 0, min, max; vector<long long int> A; cin >> N; rep(i, N) { long long int tmp; cin >> tmp; A.push_back(tmp); } sort(A.begin(), A.end(), greater<long long in...
#define rep(i, n) for (int i = 0; i < (int)(n); i++) #include <bits/stdc++.h> using namespace std; int main() { long long int N, res = 0, min, max; vector<long long int> A; cin >> N; rep(i, N) { long long int tmp; cin >> tmp; A.push_back(tmp); } sort(A.begin(), A.end(), greater<long long in...
[["-", 0, 9, 0, 7, 15, 16, 12, 16, 17, 72], ["-", 0, 9, 0, 7, 15, 16, 12, 16, 12, 13], ["-", 0, 7, 10, 43, 49, 50, 51, 16, 12, 13], ["+", 0, 7, 10, 43, 49, 50, 51, 16, 12, 13], ["-", 0, 11, 12, 69, 341, 342, 0, 16, 17, 33], ["-", 0, 11, 12, 69, 341, 342, 0, 16, 12, 13]]
1
269
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < int(n); ++i) #define all(a) (a).begin(), (a).end() typedef long long ll; #define rep1(i, n) for (int i = 1; i <= int(n); ++i) int main(void) { int n; cin >> n; vector<ll> a(n); rep(i, n) cin >> a[i]; sort(all(a), greater<ll>(...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < int(n); ++i) #define all(a) (a).begin(), (a).end() typedef long long ll; #define rep1(i, n) for (int i = 1; i <= int(n); ++i) int main(void) { int n; cin >> n; vector<ll> a(n); rep(i, n) cin >> a[i]; sort(all(a), greater<ll>(...
[["-", 0, 9, 0, 1, 0, 11, 12, 118, 119, 120], ["+", 0, 9, 0, 1, 0, 11, 12, 118, 119, 120]]
1
196
from sys import stdin N = int(stdin.readline().rstrip()) ran = [int(x) for x in stdin.readline().rstrip().split()] ran.sort(reverse=True) gen = len(ran) - 2 goukei = ran[0] if gen % 2 == 0: for i in range(int(gen/2)): goukei += 2 * ran[i + 1] else: for i in rangen(int((gen-1)/2)): goukei += 2 * ran[i + 1] ...
from sys import stdin N = int(stdin.readline().rstrip()) ran = [int(x) for x in stdin.readline().rstrip().split()] ran.sort(reverse=True) gen = len(ran) - 2 goukei = ran[0] if gen % 2 == 0: for i in range(int(gen/2)): goukei += 2 * ran[i + 1] else: for i in range(int((gen-1)/2)): goukei += 2 * ran[i + 1] ...
[["-", 75, 76, 8, 196, 0, 7, 12, 652, 63, 22], ["+", 75, 76, 8, 196, 0, 7, 12, 652, 63, 22]]
5
135
#include <bits/stdc++.h> using namespace std; #define int long long typedef pair<int, int> ii; typedef vector<int> vi; typedef vector<ii> vii; #define pb push_back #define ld long double #define f first #define s second #define in insert #define sz(x) (int)x.size() #define all(x) (x).begin(), (x).end() #define speed ...
#include <bits/stdc++.h> using namespace std; #define int long long typedef pair<int, int> ii; typedef vector<int> vi; typedef vector<ii> vii; #define pb push_back #define ld long double #define f first #define s second #define in insert #define sz(x) (int)x.size() #define all(x) (x).begin(), (x).end() #define speed ...
[["-", 12, 16, 12, 16, 12, 69, 341, 342, 0, 13], ["+", 12, 16, 12, 16, 12, 69, 341, 342, 0, 22]]
1
235
# -*- coding: utf-8 -*- import sys import math from bisect import bisect_left from bisect import bisect_right from collections import defaultdict from heapq import heappop, heappush import itertools import random from collections import deque from decimal import * import queue input = sys.stdin.readline def inputInt(...
# -*- coding: utf-8 -*- import sys import math from bisect import bisect_left from bisect import bisect_right from collections import defaultdict from heapq import heappop, heappush import itertools import random from collections import deque from decimal import * import queue input = sys.stdin.readline def inputInt(...
[["+", 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
235
#include <bits/stdc++.h> #define ll long long #define ld long double #define fi first #define se second #define vll vector<ll> #define pii pair<ll, ll> #define vvll vector<vector<ll>> #define pb push_back #define sz(v) (ll)(v).size() #define inf 1e18 #define md 1000000007 #define all(v) (v).begin(), (v).end() #define r...
#include <bits/stdc++.h> #define ll long long #define ld long double #define fi first #define se second #define vll vector<ll> #define pii pair<ll, ll> #define vvll vector<vector<ll>> #define pb push_back #define sz(v) (ll)(v).size() #define inf 1e18 #define md 1000000007 #define all(v) (v).begin(), (v).end() #define r...
[["-", 0, 14, 8, 9, 0, 43, 39, 344, 141, 78], ["+", 0, 14, 8, 9, 0, 43, 39, 344, 141, 78]]
1
323
N = gets.strip.to_i A = gets.strip.split(' ').map(&:to_i).sort sum = A[-1] b = 0 puts N-2 (N-2).times do |i| sum += A[A.size-(b/2)-2] b+=1 end puts sum
N = gets.strip.to_i A = gets.strip.split(' ').map(&:to_i).sort sum = A[-1] b = 0 (N-2).times do |i| sum += A[A.size-(b/2)-2] b+=1 end puts sum
[["-", 36, 36, 36, 36, 0, 493, 0, 652, 735, 22], ["-", 0, 493, 0, 652, 3, 4, 0, 738, 31, 743], ["-", 0, 493, 0, 652, 3, 4, 0, 738, 17, 33], ["-", 0, 493, 0, 652, 3, 4, 0, 738, 12, 612]]
4
74
#include <bits/stdc++.h> using namespace std; using VVI = vector<vector<int>>; using VI = vector<int>; const static string el = "\n"; int h, w, k; int result = 0; int main() { int n; cin >> n; vector<long long> a(n); for (int i = 0; i < n; i++) { long long tmp; cin >> tmp; a[i] = tmp; } sort(a....
#include <bits/stdc++.h> using namespace std; using VVI = vector<vector<int>>; using VI = vector<int>; const static string el = "\n"; int h, w, k; int result = 0; int main() { int n; cin >> n; vector<long long> a(n); for (int i = 0; i < n; i++) { long long tmp; cin >> tmp; a[i] = tmp; } sort(a....
[["-", 0, 191, 51, 83, 0, 69, 341, 342, 0, 13], ["+", 0, 191, 51, 83, 0, 69, 341, 342, 0, 13]]
1
364
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define Sort(v) sort((v).begin(), (v).end()) using veci = vector<int>; using vecs = vector<string>; using vecd = vector<double>; using vecl = vector<long long>; using G = vector<vector<int>>; using ll = long long; using P = pa...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define Sort(v) sort((v).begin(), (v).end()) using veci = vector<int>; using vecs = vector<string>; using vecd = vector<double>; using vecl = vector<long long>; using G = vector<vector<int>>; using ll = long long; using P = pa...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
217
#include <bits/stdc++.h> #define pb push_back #define rep(i, n) for (int i = 0; i < (n); i++) #define reps(i, n, s) for (int i = (s); i < (n); i++) #define rrep(i, n) for (int i = (n - 1); i >= 0; i--) #define rreps(i, n, s) for (int i = s; i >= n; i--) template <class T> bool chmax(T &a, const T &b) { if (a < b) { ...
#include <bits/stdc++.h> #define pb push_back #define rep(i, n) for (int i = 0; i < (n); i++) #define reps(i, n, s) for (int i = (s); i < (n); i++) #define rrep(i, n) for (int i = (n - 1); i >= 0; i--) #define rreps(i, n, s) for (int i = s; i >= n; i--) template <class T> bool chmax(T &a, const T &b) { if (a < b) { ...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
1
282
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> P; const int INF = 1e9; const int MOD = 1e9 + 7; int main() { int N; cin >> N; ll a[N]; for (int i = 0; i < N; i++) { cin >> a[i]; } sort(a, a + N, greater<ll>()); int cnt = 0; int pow = 1; int ind = 0; ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> P; const int INF = 1e9; const int MOD = 1e9 + 7; int main() { int N; cin >> N; ll a[N]; for (int i = 0; i < N; i++) { cin >> a[i]; } sort(a, a + N, greater<ll>()); int cnt = 0; int pow = 1; int ind = 0; ...
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 17, 108], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 107]]
1
159
#include <bits/stdc++.h> #define rep(i, n) for (long long i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; int main() { ll n; cin >> n; vector<ll> vec(n); rep(i, n) { cin >> vec[i]; } sort(vec.begin(), vec.end()); reverse(vec.begin(), vec.end()); if (n % 2 == 0) {...
#include <bits/stdc++.h> #define rep(i, n) for (long long i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; int main() { ll n; cin >> n; vector<ll> vec(n); rep(i, n) { cin >> vec[i]; } sort(vec.begin(), vec.end()); reverse(vec.begin(), vec.end()); if (n % 2 == 0) {...
[["-", 0, 11, 12, 16, 31, 23, 0, 16, 17, 33], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 17, 72], ["+", 12, 16, 12, 69, 341, 342, 0, 16, 17, 33], ["+", 12, 16, 12, 69, 341, 342, 0, 16, 12, 13]]
1
202
#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.at(i); } sort(a.begin(), a.end()); reverse(a.begin(), a.end()); long long int ans = 0; for (int i = 0; i < n - 1; i++) { ans += a.at(i); } cout << ans << ...
#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.at(i); } sort(a.begin(), a.end()); reverse(a.begin(), a.end()); long long int ans = 0; for (int i = 1; i < n; i++) { ans += a.at(i / 2); } cout << ans << ...
[["-", 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, 2, 3, 4, 0, 16, 17, 85], ["+", 0, 11, 12, 2, 3, 4, 0, 16, 12, 13]]
1
123
// #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pint; typedef pair<ll, ll> pll; typedef pair<int, pint> ppint; typedef pair<ll, pll> ppll; typedef vector<int> vint; typedef vector<ll> vll; const double pi = 3.141592653589793; const int INF10 = 1000000001; const ll INF15 ...
// #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pint; typedef pair<ll, ll> pll; typedef pair<int, pint> ppint; typedef pair<ll, pll> ppll; typedef vector<int> vint; typedef vector<ll> vll; const double pi = 3.141592653589793; const int INF10 = 1000000001; const ll INF15 ...
[["-", 8, 9, 0, 43, 39, 344, 3, 347, 0, 21], ["-", 39, 344, 3, 347, 0, 77, 39, 344, 141, 78], ["-", 3, 347, 0, 77, 39, 344, 3, 347, 0, 18], ["-", 0, 77, 39, 344, 3, 347, 0, 77, 39, 40], ["-", 3, 347, 0, 77, 39, 344, 3, 347, 0, 47]]
1
1,271
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll f(ll x) { ll ans = 0; for (ll i = 1; i <= x; ++i) { if (x % i == 0) ++ans; } return ans; } int main() { ios::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; vector<ll> a(n); for (int i = 0; i < n; ++i) { ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll f(ll x) { ll ans = 0; for (ll i = 1; i <= x; ++i) { if (x % i == 0) ++ans; } return ans; } int main() { ios::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; vector<ll> a(n); for (int i = 0; i < n; ++i) { ...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 147], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 146]]
1
197
import com.sun.jdi.ArrayReference; import com.sun.source.tree.WhileLoopTree; import java.io.*; import java.util.*; import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; public class Main { static long startTime; static long endTime; static Boolean[] prime; static Scanner sc = new Scanner(System.in); ...
import com.sun.jdi.ArrayReference; import com.sun.source.tree.WhileLoopTree; import java.io.*; import java.util.*; import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; public class Main { static long startTime; static long endTime; static Boolean[] prime; static Scanner sc = new Scanner(System.in); ...
[["-", 0, 195, 8, 196, 0, 57, 75, 196, 0, 46], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 46]]
3
968
from collections import deque N = int(input()) A = list(map(int, input().split())) A_sorted = sorted(A, reverse=True) ans = 0 queue = deque([A_sorted[0]]) for a in A[1:]: ans += queue.popleft() queue.append(a) queue.append(a) print(ans)
from collections import deque N = int(input()) A = list(map(int, input().split())) A_sorted = sorted(A, reverse=True) ans = 0 queue = deque([A_sorted[0]]) for a in A_sorted[1:]: ans += queue.popleft() queue.append(a) queue.append(a) print(ans)
[["-", 36, 36, 0, 656, 0, 7, 12, 206, 51, 22], ["+", 36, 36, 0, 656, 0, 7, 12, 206, 51, 22]]
5
85
def main(): N = int(input()) lst = sorted([int(i) for i in input().split()], reverse=True) ans = lst[0] n, m = divmod(N - 2, 2) ans += sum(lst[1:n + 1]) * 2 if m: ans += lst[n + 2] print(ans) if __name__ == '__main__': main()
def main(): N = int(input()) lst = sorted([int(i) for i in input().split()], reverse=True) ans = lst[0] n, m = divmod(N - 2, 2) ans += sum(lst[1:n + 1]) * 2 if m: ans += lst[n + 1] print(ans) if __name__ == '__main__': main()
[["-", 0, 1, 0, 677, 12, 206, 206, 657, 12, 612], ["+", 0, 1, 0, 677, 12, 206, 206, 657, 12, 612]]
5
96
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; vector<long long> A(n); for (long i = 0; i < n; i++) cin >> A[i]; sort(A.begin(), A.end(), greater<long long>()); long long ans = A[0]; //最大値を格納 if (n % 2 == 0) { for (int i = 1; i < (n / 2); i++) { ans += A[i]...
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; vector<long long> A(n); for (long i = 0; i < n; i++) cin >> A[i]; sort(A.begin(), A.end(), greater<long long>()); long long ans = A[0]; //最大値を格納 if (n % 2 == 0) { for (int i = 1; i < (n / 2); i++) { ans += A[i]...
[["-", 15, 16, 12, 23, 0, 16, 31, 23, 0, 24], ["-", 15, 16, 12, 23, 0, 16, 31, 23, 0, 25], ["-", 0, 7, 15, 16, 12, 23, 0, 16, 17, 33], ["-", 0, 7, 15, 16, 12, 23, 0, 16, 12, 13], ["-", 0, 11, 12, 69, 341, 342, 0, 16, 17, 33], ["-", 0, 11, 12, 69, 341, 342, 0, 16, 12, 13]]
1
176
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; priority_queue<int> A; for (int n = 0; n < N; n++) { int a; cin >> a; A.push(a); } int ans = A.top(); A.pop(); int num = 2; while (num < N) { ans += A.top(); num++; if (num % 2 != 0) { A.pop();...
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; priority_queue<long> A; for (int n = 0; n < N; n++) { long a; cin >> a; A.push(a); } long ans = A.top(); A.pop(); int num = 2; while (num < N) { ans += A.top(); num++; if (num % 2 == 0) { A.pop...
[["-", 0, 43, 39, 344, 3, 347, 0, 77, 39, 40], ["+", 39, 344, 3, 347, 0, 77, 39, 86, 0, 96], ["-", 8, 9, 0, 7, 8, 9, 0, 43, 39, 40], ["+", 0, 7, 8, 9, 0, 43, 39, 86, 0, 96], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 79], ["+", 8, 9, 0, 57...
1
116
// // main.cpp // chat in a circle // // Created by Bryan on 05/07/20. // Copyright © 2020 mac. All rights reserved. // #include <algorithm> #include <iostream> #include <stdio.h> using namespace std; int main() { long long N; scanf("%lld", &N); long long arr[N + 3]; for (long long f = 0; f < N; f++) ...
// // main.cpp // chat in a circle // // Created by Bryan on 05/07/20. // Copyright © 2020 mac. All rights reserved. // #include <algorithm> #include <iostream> #include <stdio.h> using namespace std; int main() { long long N; scanf("%lld", &N); long long arr[N + 3]; for (long long f = 0; f < N; f++) ...
[["-", 0, 9, 0, 1, 0, 11, 12, 16, 17, 72], ["-", 0, 9, 0, 1, 0, 11, 12, 16, 12, 13]]
1
161
N = int(input()) A_i = list(map(int, input().split())) forret = sorted(A_i) ret = A_i[-1] for i in range(N-2): ret = ret + forret[-1-1-(i//2)] print(ret)
N = int(input()) A_i = list(map(int, input().split())) forret = sorted(A_i) ret = forret[-1] for i in range(N-2): ret = ret + forret[-1-1-(i//2)] print(ret)
[["-", 0, 656, 0, 1, 0, 662, 12, 206, 51, 22], ["+", 0, 656, 0, 1, 0, 662, 12, 206, 51, 22]]
5
69
n = int(input()) a = list(map(int,input().split())) a.sort(reverse = True) c = n - 2 ans = a[0] idx = 1 while c > 0: ans += a[idx] * min(c,2) idx += min(c,2) c -= min(c,2) print(ans)
n = int(input()) a = list(map(int,input().split())) a.sort(reverse = True) c = n - 2 ans = a[0] idx = 1 while c > 0: ans += a[idx] * min(c,2) idx += 1 c -= min(c,2) print(ans)
[["-", 8, 196, 0, 1, 0, 677, 12, 652, 63, 22], ["-", 0, 1, 0, 677, 12, 652, 3, 4, 0, 24], ["-", 0, 1, 0, 677, 12, 652, 3, 4, 0, 22], ["-", 0, 1, 0, 677, 12, 652, 3, 4, 0, 21], ["-", 0, 1, 0, 677, 12, 652, 3, 4, 0, 612], ["-", 0, 1, 0, 677, 12, 652, 3, 4, 0, 25], ["+", 0, 52, 8, 196, 0, 1, 0, 677, 12, 612]]
5
85
#include <algorithm> // アルゴリズム #include <cmath> // #include <iostream> #include <map> // map #include <set> // set #include <sstream> // istringstream #include <string> // 文字列 #include <vector> // vector using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) // for文の省略 int main() { // inp...
#include <algorithm> // アルゴリズム #include <cmath> // #include <iostream> #include <map> // map #include <set> // set #include <sstream> // istringstream #include <string> // 文字列 #include <vector> // vector using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) // for文の省略 int main() { // inp...
[["+", 0, 11, 12, 69, 341, 342, 0, 16, 17, 33], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 12, 13]]
1
180
n = int(input()) a = list(map(int,input().split())) a.sort(reverse=True) ans = 0 if len(a) % 2 == 0: b = a[:len(a)//2] ans = 2 * sum(b) - b[0] else: print(1) b = a[:len(a)//2 +1] ans = 2 * sum(b) - b[0] - b[-1] print(ans)
n = int(input()) a = list(map(int,input().split())) a.sort(reverse=True) ans = 0 if len(a) % 2 == 0: b = a[:len(a)//2] ans = (2 * sum(b)) - b[0] else: b = a[:len(a)//2 +1] ans = 2 * sum(b) - b[0] - b[-1] print(ans)
[["+", 0, 1, 0, 662, 12, 657, 31, 23, 0, 24], ["+", 0, 1, 0, 662, 12, 657, 31, 23, 0, 25], ["-", 75, 76, 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, 612], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
5
114
#include <bits/stdc++.h> #include <iostream> using namespace std; int main() { long int n; cin >> n; long long int a[n]; for (long int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n, greater<long long int>()); long long int ans = 0, cur = 0, t1 = 0; for (long int i = 1; i < n; i++) { if (i == 1) {...
#include <bits/stdc++.h> #include <iostream> using namespace std; int main() { long int n; cin >> n; long long int a[n]; for (long int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n, greater<long long int>()); long long int ans = 0, cur = 0, t1 = 0; for (long int i = 1; i < n; i++) { if (i == 1) {...
[["+", 75, 76, 0, 9, 0, 57, 64, 9, 0, 45], ["+", 0, 57, 64, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 27, 17, 29], ["+", 0, 9, 0, 57, 64, 9, 0, 1, 0, 35], ["+", 75, 76, 0, 9, 0, 57, 64, 9, 0, 46]]
1
150
// Problem : D - Chat in a Circle // Contest : AtCoder - AtCoder Beginner Contest 173 // URL : https://atcoder.jp/contests/abc173/tasks/abc173_d // Memory Limit : 1024 MB // Time Limit : 2000 ms // Powered by CP Editor (https://github.com/cpeditor/cpeditor) // Muallif: Azimjon Mehmonali o'g'li #include <bits/stdc++....
// Problem : D - Chat in a Circle // Contest : AtCoder - AtCoder Beginner Contest 173 // URL : https://atcoder.jp/contests/abc173/tasks/abc173_d // Memory Limit : 1024 MB // Time Limit : 2000 ms // Powered by CP Editor (https://github.com/cpeditor/cpeditor) // Muallif: Azimjon Mehmonali o'g'li #include <bits/stdc++....
[["-", 0, 11, 12, 69, 341, 342, 0, 16, 17, 33], ["-", 0, 11, 12, 69, 341, 342, 0, 16, 12, 13]]
1
409
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <fstream> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #define ll long long #define pb push_back #define clr(a, b) memset((a), (b), sizeof(a)...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <fstream> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #define ll long long #define pb push_back #define clr(a, b) memset((a), (b), sizeof(a)...
[["+", 0, 11, 12, 69, 341, 342, 0, 16, 17, 72], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 12, 13]]
1
253
#include <bits/stdc++.h> using namespace std; #define ll long long #define ull unsigned long long #define mod 1000000007 void __print(int x) { cerr << x; } void __print(long x) { cerr << x; } void __print(long long x) { cerr << x; } void __print(unsigned x) { cerr << x; } void __print(unsigned long x) { cerr << x; } v...
#include <bits/stdc++.h> using namespace std; #define ll long long #define ull unsigned long long #define mod 1000000007 void __print(int x) { cerr << x; } void __print(long x) { cerr << x; } void __print(long long x) { cerr << x; } void __print(unsigned x) { cerr << x; } void __print(unsigned long x) { cerr << x; } v...
[["+", 0, 57, 75, 76, 0, 57, 64, 9, 0, 45], ["+", 0, 57, 64, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 27, 17, 29], ["+", 75, 76, 0, 57, 64, 9, 0, 1, 0, 35], ["+", 0, 57, 75, 76, 0, 57, 64, 9, 0, 46]]
1
961
#include <bits/stdc++.h> #define int int64_t #define REP(i, n) for (int i = 0; (i) < (int)(n); ++(i)) #define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++(i)) #define REP_R(i, n) for (int i = (int)(n)-1; (i) >= 0; --(i)) #define REP3R(i, m, n) for (int i = (int)(n)-1; (i) >= (int)(m); --(i)) #define REPP(i, n) fo...
#include <bits/stdc++.h> #define int int64_t #define REP(i, n) for (int i = 0; (i) < (int)(n); ++(i)) #define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++(i)) #define REP_R(i, n) for (int i = (int)(n)-1; (i) >= 0; --(i)) #define REP3R(i, m, n) for (int i = (int)(n)-1; (i) >= (int)(m); --(i)) #define REPP(i, n) fo...
[["+", 0, 83, 0, 69, 341, 342, 0, 16, 17, 33], ["+", 0, 83, 0, 69, 341, 342, 0, 16, 12, 13]]
1
687
"use strict"; function main(arg) { const input = arg.split("\n") let N = Number(input[0]) let A = input[1].split(" ").map(Number).sort((a, b) => b - a) // console.log(A) let dp = [] // i人目入った時の心地よさ合計最大値 for (let i = 0; i < N; i++) { dp.push(0) } // dp[0] = A[0] // console.log(dp) // conso...
"use strict"; function main(arg) { const input = arg.split("\n") let N = Number(input[0]) let A = input[1].split(" ").map(Number).sort((a, b) => b - a) // console.log(A) let dp = [] // i人目入った時の心地よさ合計最大値 for (let i = 0; i < N; i++) { dp.push(0) } // dp[0] = A[0] // console.log(dp) // conso...
[["-", 64, 556, 0, 1, 0, 11, 12, 69, 500, 22], ["-", 64, 556, 0, 1, 0, 11, 12, 69, 0, 70], ["-", 64, 556, 0, 1, 0, 11, 12, 69, 0, 73]]
2
191
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(0), ios::sync_with_stdio(false); int n; cin >> n; vector<int> a(n); for (auto &&i : a) cin >> i; sort(a.rbegin(), a.rend()); vector<int> v(1, a.front()); int i = 1; while (v.size() < n) { v.emplace_back(a.at(i)); v.emplace...
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(0), ios::sync_with_stdio(false); int n; cin >> n; vector<int> a(n); for (auto &&i : a) cin >> i; sort(a.rbegin(), a.rend()); vector<int> v(1, a.front()); int i = 1; while (v.size() < n) { v.emplace_back(a.at(i)); v.emplace...
[["+", 31, 16, 12, 2, 3, 4, 0, 16, 17, 33], ["+", 31, 16, 12, 2, 3, 4, 0, 16, 12, 13], ["-", 0, 16, 31, 16, 12, 2, 3, 4, 0, 13], ["+", 0, 16, 31, 16, 12, 2, 3, 4, 0, 13]]
1
154
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ll n, m = 10000000000, ans = 0; cin >> n; vector<ll> a(n); for (ll i = 0; i < n; i++) { cin >> a[i]; } sort(a.begin(), a.end()); reverse(a.begin(), a.end()); ans += a[0]; for (ll i = 1; i < (n / 2); i++) { ans += ...
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ll n, m = 10000000000, ans = 0; cin >> n; vector<ll> a(n); for (ll i = 0; i < n; i++) { cin >> a[i]; } sort(a.begin(), a.end()); reverse(a.begin(), a.end()); ans += a[0]; for (ll i = 1; i < (n / 2); i++) { ans += ...
[["-", 0, 11, 12, 69, 341, 342, 0, 16, 17, 72], ["-", 0, 11, 12, 69, 341, 342, 0, 16, 12, 13]]
1
158
N = int(input()) A = list(map(int, input().split())) sA = sorted(A, reverse=True) if N % 2 == 0: res = sum(sA[:N//2]) * 2 - sA[0] else: res = sum(sA[:N//2]) * 2 - sA[0] + sA[N//2+1] print(res)
N = int(input()) A = list(map(int, input().split())) sA = sorted(A, reverse=True) if N % 2 == 0: res = sum(sA[:N//2]) * 2 - sA[0] else: res = sum(sA[:N//2]) * 2 - sA[0] + sA[N//2] print(res)
[["-", 0, 662, 12, 657, 12, 206, 206, 657, 17, 72], ["-", 0, 662, 12, 657, 12, 206, 206, 657, 12, 612]]
5
95
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define _GLIBCXX_DEBUG #define all(v) v.begin(), v.end() int main() { int N; cin >> N; vector<int64_t> A(N); rep(i, N) { cin >> A[i]; } sort(all(A)); reverse(all(A)); int64_t score = 0; for (int i = 1; ...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define _GLIBCXX_DEBUG #define all(v) v.begin(), v.end() int main() { int N; cin >> N; vector<int64_t> A(N); rep(i, N) { cin >> A[i]; } sort(all(A)); reverse(all(A)); int64_t score = 0; for (int i = 0; ...
[["-", 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]]
1
118
#include <stdio.h> void comb_sort(int *array, int size) { int h = size; bool is_swapped = false; while (h > 1 || is_swapped) { if (h > 1) { h = (h * 10) / 13; } is_swapped = false; for (int i = 0; i < size - h; ++i) { if (array[i] > array[i + h]) { // swap int temp = ...
#include <stdio.h> void comb_sort(int *array, int size) { int h = size; bool is_swapped = false; while (h > 1 || is_swapped) { if (h > 1) { h = (h * 10) / 13; } is_swapped = false; for (int i = 0; i < size - h; ++i) { if (array[i] < array[i + h]) { // swap int temp = ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18]]
1
245
/************************************/ /* NoobM */ /* File Name : atjp.cpp */ /* Date : 05.07.2020 18:00:02 +06 */ /************************************/ #include <bits/stdc++.h> #define rr(i, b) for (int i = 0; i < int(b); i++) #define vi(n, a) \...
/************************************/ /* NoobM */ /* File Name : atjp.cpp */ /* Date : 05.07.2020 18:00:02 +06 */ /************************************/ #include <bits/stdc++.h> #define rr(i, b) for (int i = 0; i < int(b); i++) #define vi(n, a) \...
[["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
1
187
n = int(input()) coms = list(map(int, input().split())) sr = sorted(coms) ans = 0 for i in range(n - 1): if i == 0: ans += sr[0] else: nth = (i + 1) // 2 ans += sr[nth] print(ans)
n = int(input()) coms = list(map(int, input().split())) sr = sorted(coms, reverse=True) ans = 0 for i in range(n-1): if i == 0: ans += sr[0] else: nth = (i + 1) // 2 ans += sr[nth] 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
N = int(input()) A = list(map(int,input().split())) A = sorted(A) ans = A[N//2:] if N//2 == 0: print(sum(ans)*2 - max(ans)) else: print(sum(ans)*2 - max(ans) - min(ans))
N = int(input()) A = list(map(int,input().split())) A = sorted(A) ans = A[N//2:] if N%2 == 0: print(sum(ans)*2 - max(ans)) else: print(sum(ans)*2 - max(ans) - min(ans))
[["-", 0, 656, 0, 57, 15, 666, 0, 657, 17, 676], ["+", 0, 656, 0, 57, 15, 666, 0, 657, 17, 109]]
5
82
# /usr/bin/python3 # -*- coding: utf-8 -*- from queue import Queue from queue import LifoQueue as Stack from math import sqrt, floor, ceil, log2, log10, pi from math import gcd from itertools import permutations, combinations from operator import itemgetter from functools import cmp_to_key INF=1001001001 __MOD__=(10*...
# /usr/bin/python3 # -*- coding: utf-8 -*- from queue import Queue from queue import LifoQueue as Stack from math import sqrt, floor, ceil, log2, log10, pi from math import gcd from itertools import permutations, combinations from operator import itemgetter from functools import cmp_to_key INF=1001001001 __MOD__=(10*...
[["+", 64, 196, 0, 1, 0, 677, 12, 657, 17, 33], ["+", 64, 196, 0, 1, 0, 677, 12, 657, 12, 612]]
5
1,196
#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(), greater<int>()); int ans = a[0]; for (int i = 2; i < n; ++i) { ans += a[(i + 1) / 2]; } cout << ans << endl; }
#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(), greater<int>()); long long ans = a[0]; for (int i = 2; i < n; ++i) { ans += a[i / 2]; } cout << ans << endl; }
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["-", 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
114
n = int(input()) goods = [int(x) for x in input().split()] goods.sort(reverse=True) score = 0 if len(goods) % 2 == 0: r = int(len(goods) / 2) score += goods[0] for i in range(1, r): score += goods[i] * 2 else: r = int((len(goods) - 1) / 2) score += goods[0] score += goods[r + 1] ...
n = int(input()) goods = [int(x) for x in input().split()] goods.sort(reverse=True) score = 0 if len(goods) % 2 == 0: r = int(len(goods) / 2) score += goods[0] for i in range(1, r): score += goods[i] * 2 else: r = int((len(goods) - 1) / 2) score += goods[0] score += goods[r] f...
[["-", 0, 1, 0, 677, 12, 206, 206, 657, 17, 72], ["-", 0, 1, 0, 677, 12, 206, 206, 657, 12, 612]]
5
135
#include <bits/stdc++.h> using namespace std; #define ll long long #define mod 1000000007 #define endl "\n" #define p pair<int, int> #define arrinp(i, a, start, end) \ ; \ for (ll i = start; i <=...
#include <bits/stdc++.h> using namespace std; #define ll long long #define mod 1000000007 #define endl "\n" #define p pair<int, int> #define arrinp(i, a, start, end) \ ; \ for (ll i = start; i <=...
[["-", 0, 52, 8, 9, 0, 1, 0, 27, 28, 22], ["-", 0, 52, 8, 9, 0, 1, 0, 27, 17, 68], ["-", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
1
259
#include <bits/stdc++.h> using namespace std; #define int long long signed main() { int n; cin >> n; int a[n], sum = 0; for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n); sum = a[n - 1]; for (int i = 0; i < n - 2; i++) { sum += a[n - 1 - i / 2]; } cout << sum << '\n'; }
#include <bits/stdc++.h> using namespace std; #define int long long signed main() { int n; cin >> n; int a[n], sum = 0; for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n); sum = a[n - 1]; for (int i = 0; i < n - 2; i++) { sum += a[n - 2 - i / 2]; } cout << sum << '\n'; }
[["-", 12, 69, 341, 342, 0, 16, 31, 16, 12, 13], ["+", 12, 69, 341, 342, 0, 16, 31, 16, 12, 13]]
1
112