| 模型 | 模型答案 | 正确答案 |
|---|---|---|
| 金声玉亮2.0 | ```python import sys from bisect import bisect_right input = sys.stdin.read data = input().split() N = int(data[0]) A = list(map(int, data[1:])) # Sort the list A and calculate the prefix sums sorted_A = sorted(A) prefix_sums = [0] * (N + 1) for i in range(N): prefix_sums[i + 1] = prefix_sums[i] + sorted_A[i] # Calculate the sum of elements greater than each A_i results = [] for i in range(N): idx = bisect_right(sorted_A, A[i]) result = prefix_sums[N] - prefix_sums[idx] results.append(result) # Print the results print(" ".join(map(str, results))) ``` |
[{"input": "5\n1 4 1 4 2\n", "output": "10 0 10 0 8\n", "testtype": "stdin"}, {"input": "10\n31 42 59 26 53 58 97 93 23 54\n", "output": "456 414 190 487 361 249 0 97 513 307\n", "testtype": "stdin"}, {"input": "50\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n", "output": "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n", "testtype": "stdin"}] |
| deepseek-r1 | ```python import bisect n = int(input()) a = list(map(int, input().split())) sorted_a = sorted(a) prefix = [0] current = 0 for num in sorted_a: current += num prefix.append(current) total = prefix[-1] result = [str(total - prefix[bisect.bisect_right(sorted_a, x)]) for x in a] print(' '.join(result)) ``` |
[{"input": "5\n1 4 1 4 2\n", "output": "10 0 10 0 8\n", "testtype": "stdin"}, {"input": "10\n31 42 59 26 53 58 97 93 23 54\n", "output": "456 414 190 487 361 249 0 97 513 307\n", "testtype": "stdin"}, {"input": "50\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n", "output": "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n", "testtype": "stdin"}] |
| gpto1 | ```python # YOUR CODE HERE import sys import threading def main(): import bisect N_and_rest = sys.stdin.read().split() N = int(N_and_rest[0]) A = list(map(int, N_and_rest[1:N+1])) N = len(A) S = sum(A) sorted_A = sorted(A) N = len(sorted_A) suffix_sum = [0]*(N+1) for i in range(N-1,-1,-1): suffix_sum[i] = suffix_sum[i+1] + sorted_A[i] sum_for_v = {} for v in set(A): idx = bisect.bisect_right(sorted_A, v) sum_for_v[v] = suffix_sum[idx] result = [str(sum_for_v[a]) for a in A] print(' '.join(result)) threading.Thread(target=main).start() ``` |
[{"input": "5\n1 4 1 4 2\n", "output": "10 0 10 0 8\n", "testtype": "stdin"}, {"input": "10\n31 42 59 26 53 58 97 93 23 54\n", "output": "456 414 190 487 361 249 0 97 513 307\n", "testtype": "stdin"}, {"input": "50\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n", "output": "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n", "testtype": "stdin"}] |
| gpt-4o-2024-08-06 | ```python # YOUR CODE HERE import sys input = sys.stdin.read def solve(): data = input().strip().split() N = int(data[0]) A = list(map(int, data[1:])) # Create a list of tuples (value, index) and sort it by value indexed_A = sorted((value, index) for index, value in enumerate(A)) # Prepare an array to store the results results = [0] * N # Total sum of all elements total_sum = sum(A) # Current sum of elements processed current_sum = 0 # Iterate over the sorted list for i in range(N): value, index = indexed_A[i] # The sum of elements greater than A[index] is total_sum - current_sum - value results[index] = total_sum - current_sum - value # Update the current sum current_sum += value # Print the results print(' '.join(map(str, results))) solve() ``` |
[{"input": "5\n1 4 1 4 2\n", "output": "10 0 10 0 8\n", "testtype": "stdin"}, {"input": "10\n31 42 59 26 53 58 97 93 23 54\n", "output": "456 414 190 487 361 249 0 97 513 307\n", "testtype": "stdin"}, {"input": "50\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n", "output": "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n", "testtype": "stdin"}] |
| Qwen2-72B-Instruct | ```python from bisect import bisect_left, bisect_right from itertools import accumulate N = int(input()) A = list(map(int, input().split())) # Create a list of unique elements sorted unique_elements = sorted(set(A)) # Create a dictionary to map each element to its index in the sorted unique list index_map = {value: index for index, value in enumerate(unique_elements)} # Create a list to store the cumulative sum of elements greater than each element in the sorted unique list cumulative_sum = [0] * len(unique_elements) for i in range(len(unique_elements) - 1, -1, -1): if i < len(unique_elements) - 1: cumulative_sum[i] = cumulative_sum[i + 1] cumulative_sum[i] += unique_elements[i] # Create a list to store the number of occurrences of each element occurrences = [0] * len(unique_elements) # Count the occurrences of each element in A for a in A: occurrences[index_map[a]] += 1 # Calculate the prefix sum of occurrences prefix_sum = list(accumulate(occurrences)) # Calculate the result for each element in A result = [] for a in A: index = index_map[a] # The number of elements greater than 'a' is the total number of elements minus the number of elements up to 'a' num_greater = N - prefix_sum[index] # The sum of elements greater than 'a' is the total sum minus the sum of elements up to 'a' times the number of elements greater than 'a' sum_greater = cumulative_sum[0] - cumulative_sum[index] - a * num_greater result.append(sum_greater) print(*result) ``` This solution uses binary search (via `bisect`) to find the position of each element in the sorted list of unique elements, then calculates the number of elements greater than each element and their sum using prefix sums and cumulative sums. |
[{"input": "5\n1 4 1 4 2\n", "output": "10 0 10 0 8\n", "testtype": "stdin"}, {"input": "10\n31 42 59 26 53 58 97 93 23 54\n", "output": "456 414 190 487 361 249 0 97 513 307\n", "testtype": "stdin"}, {"input": "50\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n", "output": "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n", "testtype": "stdin"}] |
| DeepSeek-Coder-V2-Lite-Instruct | ```python # YOUR CODE HERE import sys # Read input N = int(sys.stdin.readline().strip()) A = list(map(int, sys.stdin.readline().strip().split())) # Calculate the sum of elements greater than each element in A B = [] for i in range(N): greater_sum = sum(A[j] for j in range(N) if A[j] > A[i]) B.append(greater_sum) # Print the results print(' '.join(map(str, B))) ``` |
[{"input": "5\n1 4 1 4 2\n", "output": "10 0 10 0 8\n", "testtype": "stdin"}, {"input": "10\n31 42 59 26 53 58 97 93 23 54\n", "output": "456 414 190 487 361 249 0 97 513 307\n", "testtype": "stdin"}, {"input": "50\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n", "output": "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n", "testtype": "stdin"}] |
| Meta-Llama-3.1-405B-Instruct-Turbo | ```python import sys def read_ints(): return list(map(int, sys.stdin.readline().strip().split())) def main(): n = int(sys.stdin.readline().strip()) a = read_ints() b = sorted(a) prefix_sum = [0] * (n + 1) for i in range(n): prefix_sum[i + 1] = prefix_sum[i] + b[i] def find_sum(x): idx = next((i for i, val in enumerate(b) if val > x), n) return prefix_sum[n] - prefix_sum[idx] result = [find_sum(x) for x in a] print(' '.join(map(str, result))) if __name__ == "__main__": main() ``` |
[{"input": "5\n1 4 1 4 2\n", "output": "10 0 10 0 8\n", "testtype": "stdin"}, {"input": "10\n31 42 59 26 53 58 97 93 23 54\n", "output": "456 414 190 487 361 249 0 97 513 307\n", "testtype": "stdin"}, {"input": "50\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n", "output": "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n", "testtype": "stdin"}] |
| Meta-Llama-3.1-70B-Instruct-Turbo | ```python import sys input = sys.stdin.readline n = int(input()) a = list(map(int, input().split())) b = sorted(a) c = [0] * n for i in range(n): c[i] = b[i] + c[i-1] if i > 0 else b[i] ans = [] for i in range(n): idx = b.index(a[i]) ans.append(c[-1] - c[idx] - (c[idx] - c[idx-1] if idx > 0 else 0)) print(*ans) ``` |
[{"input": "5\n1 4 1 4 2\n", "output": "10 0 10 0 8\n", "testtype": "stdin"}, {"input": "10\n31 42 59 26 53 58 97 93 23 54\n", "output": "456 414 190 487 361 249 0 97 513 307\n", "testtype": "stdin"}, {"input": "50\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n", "output": "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n", "testtype": "stdin"}] |
| baichuan4 | ```python # YOUR CODE HERE import sys # Read input from stdin input_data = sys.stdin.read().splitlines() n = int(input_data[0]) sequence = list(map(int, input_data[1].split())) # Function to calculate the sum of elements greater than a given value def sum_greater_than(value, sequence): return sum(x for x in sequence if x > value) # Calculate the sum for each element in the sequence results = [sum_greater_than(value, sequence) for value in sequence] # Print the results separated by spaces print(' '.join(map(str, results))) ``` |
[{"input": "5\n1 4 1 4 2\n", "output": "10 0 10 0 8\n", "testtype": "stdin"}, {"input": "10\n31 42 59 26 53 58 97 93 23 54\n", "output": "456 414 190 487 361 249 0 97 513 307\n", "testtype": "stdin"}, {"input": "50\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n", "output": "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n", "testtype": "stdin"}] |
| doubao | ```python import bisect N = int(input()) A = list(map(int, input().split())) sorted_A = sorted(A) prefix_sum = [0] for num in sorted_A: prefix_sum.append(prefix_sum[-1] + num) result = [] for i in range(N): index = bisect.bisect_right(sorted_A, A[i]) result.append(prefix_sum[-1] - prefix_sum[index] - A[i] * (N - index)) print(*result) ``` |
[{"input": "5\n1 4 1 4 2\n", "output": "10 0 10 0 8\n", "testtype": "stdin"}, {"input": "10\n31 42 59 26 53 58 97 93 23 54\n", "output": "456 414 190 487 361 249 0 97 513 307\n", "testtype": "stdin"}, {"input": "50\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n", "output": "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n", "testtype": "stdin"}] |
| gpto1 | ```python # YOUR CODE HERE import sys import threading def main(): import bisect N_and_rest = sys.stdin.read().split() N = int(N_and_rest[0]) A = list(map(int, N_and_rest[1:N+1])) N = len(A) S = sum(A) sorted_A = sorted(A) N = len(sorted_A) suffix_sum = [0]*(N+1) for i in range(N-1,-1,-1): suffix_sum[i] = suffix_sum[i+1] + sorted_A[i] sum_for_v = {} for v in set(A): idx = bisect.bisect_right(sorted_A, v) sum_for_v[v] = suffix_sum[idx] result = [str(sum_for_v[a]) for a in A] print(' '.join(result)) threading.Thread(target=main).start() ``` |
[{"input": "5\n1 4 1 4 2\n", "output": "10 0 10 0 8\n", "testtype": "stdin"}, {"input": "10\n31 42 59 26 53 58 97 93 23 54\n", "output": "456 414 190 487 361 249 0 97 513 307\n", "testtype": "stdin"}, {"input": "50\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n", "output": "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n", "testtype": "stdin"}] |
| kimi | ```python # YOUR CODE HERE import bisect n = int(input()) a = list(map(int, input().split())) a_sorted = sorted(a) a_sorted_index = {} for i in range(n): a_sorted_index[a_sorted[i]] = i total_sum = sum(a) ans = [] for i in range(n): idx = a_sorted_index[a[i]] count = n - idx - 1 sum_greater = total_sum - (count * a[i] + sum(a_sorted[idx+1:])) ans.append(sum_greater) print(' '.join(map(str, ans))) ``` |
[{"input": "5\n1 4 1 4 2\n", "output": "10 0 10 0 8\n", "testtype": "stdin"}, {"input": "10\n31 42 59 26 53 58 97 93 23 54\n", "output": "456 414 190 487 361 249 0 97 513 307\n", "testtype": "stdin"}, {"input": "50\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n", "output": "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n", "testtype": "stdin"}] |
| minimax | ```python # YOUR CODE HERE from sys import stdin # Read the number of elements N N = int(input()) # Read the sequence A A = list(map(int, input().split())) # Initialize an array to store the results B = [0] * N # Iterate over each element in A to calculate the sum of elements greater than A[i] for i in range(N): # Sum elements greater than A[i] B[i] = sum(A[j] for j in range(N) if A[j] > A[i]) # Print the results print(' '.join(map(str, B))) ``` |
[{"input": "5\n1 4 1 4 2\n", "output": "10 0 10 0 8\n", "testtype": "stdin"}, {"input": "10\n31 42 59 26 53 58 97 93 23 54\n", "output": "456 414 190 487 361 249 0 97 513 307\n", "testtype": "stdin"}, {"input": "50\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n", "output": "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n", "testtype": "stdin"}] |
| wenxinyiyan | ```python # Read the input size N = int(input()) # Read the sequence A = list(map(int, input().split())) # Initialize an array to hold the sums sums = [0] * N # Calculate the total sum of all elements total_sum = sum(A) # Sort the indices of A by their corresponding values sorted_indices = sorted(range(N), key=lambda i: A[i]) # Iterate over the sorted indices in reverse order current_sum = 0 for i in range(N - 1, -1, -1): index = sorted_indices[i] # Exclude the current element from the sum current_sum += A[index] # The sum of all elements greater than A[index] is the total sum minus the current element and current accumulated sum sums[index] = total_sum - A[index] - current_sum # Print the results print(' '.join(map(str, sums))) ``` |
[{"input": "5\n1 4 1 4 2\n", "output": "10 0 10 0 8\n", "testtype": "stdin"}, {"input": "10\n31 42 59 26 53 58 97 93 23 54\n", "output": "456 414 190 487 361 249 0 97 513 307\n", "testtype": "stdin"}, {"input": "50\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n", "output": "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n", "testtype": "stdin"}] |
| zhipu | ```python def main(): import sys input = sys.stdin.read data = input().split() N = int(data[0]) A = list(map(int, data[1:])) # Sort the array and calculate prefix sums sorted_A = sorted(A) prefix_sum = [0] * (N + 1) for i in range(1, N + 1): prefix_sum[i] = prefix_sum[i - 1] + sorted_A[i - 1] # Dictionary to store the sum of elements greater than each unique value sum_greater_than = {} for i in range(N): if sorted_A[i] not in sum_greater_than: sum_greater_than[sorted_A[i]] = prefix_sum[N] - prefix_sum[i + 1] # Calculate the result for each element in A result = [] for a in A: result.append(sum_greater_than[a]) # Print the result print(" ".join(map(str, result))) if __name__ == "__main__": main() ``` |
[{"input": "5\n1 4 1 4 2\n", "output": "10 0 10 0 8\n", "testtype": "stdin"}, {"input": "10\n31 42 59 26 53 58 97 93 23 54\n", "output": "456 414 190 487 361 249 0 97 513 307\n", "testtype": "stdin"}, {"input": "50\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n", "output": "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n", "testtype": "stdin"}] |
| deepseek-v3 | ```python # YOUR CODE HERE import sys import bisect def main(): input = sys.stdin.read data = input().split() N = int(data[0]) A = list(map(int, data[1:N+1])) # Create a sorted list for binary search sorted_A = sorted(A) # Precompute prefix sums for the sorted list prefix_sum = [0] * (N + 1) for i in range(N): prefix_sum[i+1] = prefix_sum[i] + sorted_A[i] # For each element in A, find the sum of elements greater than it results = [] for a in A: # Find the index of the first element greater than a idx = bisect.bisect_right(sorted_A, a) # Sum of elements from idx to the end sum_greater = prefix_sum[N] - prefix_sum[idx] results.append(sum_greater) print(' '.join(map(str, results))) if __name__ == "__main__": main() ``` |
[{"input": "5\n1 4 1 4 2\n", "output": "10 0 10 0 8\n", "testtype": "stdin"}, {"input": "10\n31 42 59 26 53 58 97 93 23 54\n", "output": "456 414 190 487 361 249 0 97 513 307\n", "testtype": "stdin"}, {"input": "50\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n", "output": "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n", "testtype": "stdin"}] |