message stringlengths 2 30.5k | message_type stringclasses 2
values | message_id int64 0 1 | conversation_id int64 237 109k | cluster float64 10 10 | __index_level_0__ int64 474 217k |
|---|---|---|---|---|---|
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given two integers x and y. You can perform two types of operations:
1. Pay a dollars and increase or decrease any of these integers by 1. For example, if x = 0 and y = 7 there are four possible outcomes after this operation:
... | instruction | 0 | 91,069 | 10 | 182,138 |
Tags: greedy, math
Correct Solution:
```
t=int(input())
for _ in range(t):
x,y=map(int,input().split())
a,b=map(int,input().split())
if x<y:
print(x*min(b,a+a) + (y-x)*a)
else:
print(y*min(b,a+a) + (x-y)*a)
``` | output | 1 | 91,069 | 10 | 182,139 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given two integers x and y. You can perform two types of operations:
1. Pay a dollars and increase or decrease any of these integers by 1. For example, if x = 0 and y = 7 there are four possible outcomes after this operation:
... | instruction | 0 | 91,070 | 10 | 182,140 |
Tags: greedy, math
Correct Solution:
```
mod=998244353
t=int(input())
for _ in range(t):
x,y=map(int,input().split())
a,b=map(int,input().split())
x1=(abs(x-y))*a + b*min(abs(x),abs(y))
x2=(x+y)*a
print(min(x1,x2))
``` | output | 1 | 91,070 | 10 | 182,141 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given two integers x and y. You can perform two types of operations:
1. Pay a dollars and increase or decrease any of these integers by 1. For example, if x = 0 and y = 7 there are four possible outcomes after this operation:
... | instruction | 0 | 91,071 | 10 | 182,142 |
Tags: greedy, math
Correct Solution:
```
t = int(input())
for i in range(t):
x, y = map(int, input().split())
a, b = map(int, input().split())
ans = 0
diff = abs(x-y)
if b > 2*a:
ans += x*a+y*a
else:
ans += diff*a + min(x, y)*b
print(ans)
``` | output | 1 | 91,071 | 10 | 182,143 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given two integers x and y. You can perform two types of operations:
1. Pay a dollars and increase or decrease any of these integers by 1. For example, if x = 0 and y = 7 there are four possible outcomes after this operation:
... | instruction | 0 | 91,072 | 10 | 182,144 |
Tags: greedy, math
Correct Solution:
```
if __name__ == "__main__":
for _ in range(int(input())):
x, y = map(int, input().split())
a, b = map(int, input().split())
b = min(b, a + a)
if x < y:
x, y= y, x
print(y * b + (x - y) * a)
``` | output | 1 | 91,072 | 10 | 182,145 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given two integers x and y. You can perform two types of operations:
1. Pay a dollars and increase or decrease any of these integers by 1. For example, if x = 0 and y = 7 there are four possible outcomes after this operation:
... | instruction | 0 | 91,073 | 10 | 182,146 |
Tags: greedy, math
Correct Solution:
```
T = int(input())
for t in range(T):
x, y = list(map(int, input().split()))
a, b = list(map(int, input().split()))
if(2*a <= b):
print((abs(x)+abs(y))*a)
continue
else:
ans = min(x, y)*b
x, y =x-min(x,y), y- min(x,y)
ans += ... | output | 1 | 91,073 | 10 | 182,147 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given two integers x and y. You can perform two types of operations:
1. Pay a dollars and increase or decrease any of these integers by 1. For example, if x = 0 and y = 7 there are f... | instruction | 0 | 91,074 | 10 | 182,148 |
Yes | output | 1 | 91,074 | 10 | 182,149 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given two integers x and y. You can perform two types of operations:
1. Pay a dollars and increase or decrease any of these integers by 1. For example, if x = 0 and y = 7 there are f... | instruction | 0 | 91,075 | 10 | 182,150 |
Yes | output | 1 | 91,075 | 10 | 182,151 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given two integers x and y. You can perform two types of operations:
1. Pay a dollars and increase or decrease any of these integers by 1. For example, if x = 0 and y = 7 there are f... | instruction | 0 | 91,076 | 10 | 182,152 |
Yes | output | 1 | 91,076 | 10 | 182,153 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given two integers x and y. You can perform two types of operations:
1. Pay a dollars and increase or decrease any of these integers by 1. For example, if x = 0 and y = 7 there are f... | instruction | 0 | 91,077 | 10 | 182,154 |
Yes | output | 1 | 91,077 | 10 | 182,155 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given two integers x and y. You can perform two types of operations:
1. Pay a dollars and increase or decrease any of these integers by 1. For example, if x = 0 and y = 7 there are f... | instruction | 0 | 91,078 | 10 | 182,156 |
No | output | 1 | 91,078 | 10 | 182,157 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given two integers x and y. You can perform two types of operations:
1. Pay a dollars and increase or decrease any of these integers by 1. For example, if x = 0 and y = 7 there are f... | instruction | 0 | 91,079 | 10 | 182,158 |
No | output | 1 | 91,079 | 10 | 182,159 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given two integers x and y. You can perform two types of operations:
1. Pay a dollars and increase or decrease any of these integers by 1. For example, if x = 0 and y = 7 there are f... | instruction | 0 | 91,080 | 10 | 182,160 |
No | output | 1 | 91,080 | 10 | 182,161 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given two integers x and y. You can perform two types of operations:
1. Pay a dollars and increase or decrease any of these integers by 1. For example, if x = 0 and y = 7 there are f... | instruction | 0 | 91,081 | 10 | 182,162 |
No | output | 1 | 91,081 | 10 | 182,163 |
Provide tags and a correct Python 3 solution for this coding contest problem.
We all know the impressive story of Robin Hood. Robin Hood uses his archery skills and his wits to steal the money from rich, and return it to the poor.
There are n citizens in Kekoland, each person has ci coins. Each day, Robin Hood will t... | instruction | 0 | 91,327 | 10 | 182,654 |
Tags: binary search, greedy
Correct Solution:
```
import sys
sys.stderr = sys.stdout
def hood(n, k, C):
C.sort()
m, r = divmod(sum(C), n)
m1 = (m + 1) if r else m
c_lo = C[0]
k_lo = k
for i, c in enumerate(C):
if c_lo == m:
break
c_m = min(c, m)
dc = c_m - ... | output | 1 | 91,327 | 10 | 182,655 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In Ann's favorite book shop are as many as n books on math and economics. Books are numbered from 1 to n. Each of them contains non-negative number of problems.
Today there is a sale: any subsegment of a segment from l to r can be bought at... | instruction | 0 | 91,381 | 10 | 182,762 |
Tags: data structures, flows, hashing
Correct Solution:
```
# ------------------- fast io --------------------
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
... | output | 1 | 91,381 | 10 | 182,763 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Nura wants to buy k gadgets. She has only s burles for that. She can buy each gadget for dollars or for pounds. So each gadget is selling only for some type of currency. The type of currency and the cost in that currency are not changing.
N... | instruction | 0 | 92,158 | 10 | 184,316 |
Tags: binary search, greedy, two pointers
Correct Solution:
```
#### IMPORTANT LIBRARY ####
############################
### DO NOT USE import random --> 250ms to load the library
############################
### In case of extra libraries: https://github.com/cheran-senthil/PyRival
######################
####### IMP... | output | 1 | 92,158 | 10 | 184,317 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Nura wants to buy k gadgets. She has only s burles for that. She can buy each gadget for dollars or for pounds. So each gadget is selling only for some type of currency. The type of currency and the cost in that currency are not changing.
N... | instruction | 0 | 92,159 | 10 | 184,318 |
Tags: binary search, greedy, two pointers
Correct Solution:
```
from itertools import accumulate
import sys
def solve(f, g):
n, m, k, s = [int(x) for x in f.readline().split()]
a_price = [(int(x), i+1) for i, x in enumerate(f.readline().split())]
b_price = [(int(x), i+1) for i, x in enumerate(f.readline().... | output | 1 | 92,159 | 10 | 184,319 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Nura wants to buy k gadgets. She has only s burles for that. She can buy each gadget for dollars or for pounds. So each gadget is selling only for some type of currency. The type of currency and the cost in that currency are not changing.
N... | instruction | 0 | 92,160 | 10 | 184,320 |
Tags: binary search, greedy, two pointers
Correct Solution:
```
from sys import stdin, stdout
def ints():
return [int(x) for x in stdin.readline().split()]
n, m, k, s = ints()
a = ints()
b = ints()
d_gad = [];
p_gad = [];
for i in range(m):
t, c = ints()
if t == 1:
d_gad.append([c, i + 1])
else:
p_gad... | output | 1 | 92,160 | 10 | 184,321 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Nura wants to buy k gadgets. She has only s burles for that. She can buy each gadget for dollars or for pounds. So each gadget is selling only for some type of currency. The type of currency and the cost in that currency are not changing.
N... | instruction | 0 | 92,161 | 10 | 184,322 |
Tags: binary search, greedy, two pointers
Correct Solution:
```
import os, sys
from io import IOBase, BytesIO
py2 = round(0.5)
if py2:
from future_builtins import ascii, filter, hex, map, oct, zip
range = xrange
BUFSIZE = 8192
class FastIO(BytesIO):
newlines = 0
def __init__(self, file):
self.... | output | 1 | 92,161 | 10 | 184,323 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Nura wants to buy k gadgets. She has only s burles for that. She can buy each gadget for dollars or for pounds. So each gadget is selling only for some type of currency. The type of currency and the cost in that currency are not changing.
N... | instruction | 0 | 92,162 | 10 | 184,324 |
Tags: binary search, greedy, two pointers
Correct Solution:
```
import sys
from itertools import accumulate
n, m, k, s = map(int, input().split())
_rate = [list(map(int, input().split())), list(map(int, input().split()))]
rate = [list(accumulate(_rate[0], min)), list(accumulate(_rate[1], min))]
items = [[[0, -1]], [[... | output | 1 | 92,162 | 10 | 184,325 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Nura wants to buy k gadgets. She has only s burles for that. She can buy each gadget for dollars or for pounds. So each gadget is selling only for some type of currency. The type of currency and the cost in that currency are not changing.
N... | instruction | 0 | 92,163 | 10 | 184,326 |
Tags: binary search, greedy, two pointers
Correct Solution:
```
# ---------------------------iye ha aam zindegi---------------------------------------------
import math
import random
import heapq, bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction
import sys
import threading
fro... | output | 1 | 92,163 | 10 | 184,327 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Nura wants to buy k gadgets. She has only s burles for that. She can buy each gadget for dollars or for pounds. So each gadget is selling only for some type of currency. The type of currency and the cost in that currency are not changing.
N... | instruction | 0 | 92,164 | 10 | 184,328 |
Tags: binary search, greedy, two pointers
Correct Solution:
```
'''
Auther: ghoshashis545 Ashis Ghosh
College: Jalpaiguri Govt Enggineering College
'''
from os import path
from io import BytesIO, IOBase
import sys
from heapq import heappush,heappop
from functools import cmp_to_key as ctk
from collections impor... | output | 1 | 92,164 | 10 | 184,329 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Nura wants to buy k gadgets. She has only s burles for that. She can buy each gadget for dollars or for pounds. So each gadget is selling only for some type of currency. The type of currency and the cost in that currency are not changing.
N... | instruction | 0 | 92,165 | 10 | 184,330 |
Tags: binary search, greedy, two pointers
Correct Solution:
```
from sys import stdin, stdout
def ints():
return [int(x) for x in stdin.readline().split()]
n, m, k, s = ints()
a = ints()
b = ints()
d_gad = [];
p_gad = [];
for i in range(m):
t, c = ints()
if t == 1:
d_gad.append([c, i + 1])
else:
p_gad... | output | 1 | 92,165 | 10 | 184,331 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Nura wants to buy k gadgets. She has only s burles for that. She can buy each gadget for dollars or for pounds. So each gadget is selling only for some type of currency. The type of currency and... | instruction | 0 | 92,166 | 10 | 184,332 |
Yes | output | 1 | 92,166 | 10 | 184,333 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Nura wants to buy k gadgets. She has only s burles for that. She can buy each gadget for dollars or for pounds. So each gadget is selling only for some type of currency. The type of currency and... | instruction | 0 | 92,167 | 10 | 184,334 |
No | output | 1 | 92,167 | 10 | 184,335 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Nura wants to buy k gadgets. She has only s burles for that. She can buy each gadget for dollars or for pounds. So each gadget is selling only for some type of currency. The type of currency and... | instruction | 0 | 92,168 | 10 | 184,336 |
No | output | 1 | 92,168 | 10 | 184,337 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Nura wants to buy k gadgets. She has only s burles for that. She can buy each gadget for dollars or for pounds. So each gadget is selling only for some type of currency. The type of currency and... | instruction | 0 | 92,169 | 10 | 184,338 |
No | output | 1 | 92,169 | 10 | 184,339 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Nura wants to buy k gadgets. She has only s burles for that. She can buy each gadget for dollars or for pounds. So each gadget is selling only for some type of currency. The type of currency and... | instruction | 0 | 92,170 | 10 | 184,340 |
No | output | 1 | 92,170 | 10 | 184,341 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A robber has attempted to rob a bank but failed to complete his task. However, he had managed to open all the safes.
Oleg the bank client loves money (who doesn't), and decides to take advantage of this failed robbery and steal some money f... | instruction | 0 | 92,283 | 10 | 184,566 |
Tags: brute force, implementation
Correct Solution:
```
class CodeforcesTask794ASolution:
def __init__(self):
self.result = ''
self.a_b_c = []
self.n = 0
self.banknotes = []
def read_input(self):
self.a_b_c = [int(x) for x in input().split(" ")]
self.n = int(inpu... | output | 1 | 92,283 | 10 | 184,567 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A robber has attempted to rob a bank but failed to complete his task. However, he had managed to open all the safes.
Oleg the bank client loves money (who doesn't), and decides to take advantage of this failed robbery and steal some money f... | instruction | 0 | 92,284 | 10 | 184,568 |
Tags: brute force, implementation
Correct Solution:
```
a, b, c = map(int, input().split())
n = int(input())
l = list(map(int, input().split()))
ans = 0
for i in l:
if i in range(b+1, c):
ans += 1
print(ans)
``` | output | 1 | 92,284 | 10 | 184,569 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A robber has attempted to rob a bank but failed to complete his task. However, he had managed to open all the safes.
Oleg the bank client loves money (who doesn't), and decides to take advantage of this failed robbery and steal some money f... | instruction | 0 | 92,285 | 10 | 184,570 |
Tags: brute force, implementation
Correct Solution:
```
a,b,c = list(map(int,input().split()))
n = int(input())
a = list(map(int,input().split()))
ans = 0
for i in a:
if b < i < c:
ans += 1
print(ans)
``` | output | 1 | 92,285 | 10 | 184,571 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A robber has attempted to rob a bank but failed to complete his task. However, he had managed to open all the safes.
Oleg the bank client loves money (who doesn't), and decides to take advantage of this failed robbery and steal some money f... | instruction | 0 | 92,286 | 10 | 184,572 |
Tags: brute force, implementation
Correct Solution:
```
def main_function():
a, b, c = [int(i) for i in input().split(" ")]
n = int(input())
x = [int(i) for i in input().split(" ")]
banknotes = 0
for i in x:
if i > b and i < c:
banknotes += 1
return str(banknotes)
print(... | output | 1 | 92,286 | 10 | 184,573 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A robber has attempted to rob a bank but failed to complete his task. However, he had managed to open all the safes.
Oleg the bank client loves money (who doesn't), and decides to take advantage of this failed robbery and steal some money f... | instruction | 0 | 92,287 | 10 | 184,574 |
Tags: brute force, implementation
Correct Solution:
```
#----Kuzlyaev-Nikita-Codeforces-----
#------------03.04.2020-------------
alph="abcdefghijklmnopqrstuvwxyz"
#-----------------------------------
a,b,c=map(int,input().split())
n=int(input())
x=list(map(int,input().split()))
E=0
for i in range(n):
if x[i]>b ... | output | 1 | 92,287 | 10 | 184,575 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A robber has attempted to rob a bank but failed to complete his task. However, he had managed to open all the safes.
Oleg the bank client loves money (who doesn't), and decides to take advantage of this failed robbery and steal some money f... | instruction | 0 | 92,288 | 10 | 184,576 |
Tags: brute force, implementation
Correct Solution:
```
a,b,c=map(int,input().split())
d=int(input())
l=list(map(int,input().split()))
i=0
e=0
while(i<d):
if l[i]>b and l[i]<c:
e+=1
i+=1
print(e)
``` | output | 1 | 92,288 | 10 | 184,577 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A robber has attempted to rob a bank but failed to complete his task. However, he had managed to open all the safes.
Oleg the bank client loves money (who doesn't), and decides to take advantage of this failed robbery and steal some money f... | instruction | 0 | 92,289 | 10 | 184,578 |
Tags: brute force, implementation
Correct Solution:
```
l=list(map(int,input().rstrip().split()))
n=int(input())
l1=list(map(int,input().rstrip().split()))
c=0
for i in l1:
if (i>l[1] and i<l[2]):
c+=1
print(c)
``` | output | 1 | 92,289 | 10 | 184,579 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A robber has attempted to rob a bank but failed to complete his task. However, he had managed to open all the safes.
Oleg the bank client loves money (who doesn't), and decides to take advantage of this failed robbery and steal some money f... | instruction | 0 | 92,290 | 10 | 184,580 |
Tags: brute force, implementation
Correct Solution:
```
(n,a,b) = [int(x) for x in input().split()]
number = int(input())
notes = [int(x) for x in input().split()]
answer = 0
for i in range(len(notes)):
if a<notes[i]<b:
answer+=1
print(answer)
``` | output | 1 | 92,290 | 10 | 184,581 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A robber has attempted to rob a bank but failed to complete his task. However, he had managed to open all the safes.
Oleg the bank client loves money (who doesn't), and decides to take advantag... | instruction | 0 | 92,291 | 10 | 184,582 |
Yes | output | 1 | 92,291 | 10 | 184,583 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A robber has attempted to rob a bank but failed to complete his task. However, he had managed to open all the safes.
Oleg the bank client loves money (who doesn't), and decides to take advantag... | instruction | 0 | 92,292 | 10 | 184,584 |
Yes | output | 1 | 92,292 | 10 | 184,585 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A robber has attempted to rob a bank but failed to complete his task. However, he had managed to open all the safes.
Oleg the bank client loves money (who doesn't), and decides to take advantag... | instruction | 0 | 92,293 | 10 | 184,586 |
Yes | output | 1 | 92,293 | 10 | 184,587 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A robber has attempted to rob a bank but failed to complete his task. However, he had managed to open all the safes.
Oleg the bank client loves money (who doesn't), and decides to take advantag... | instruction | 0 | 92,294 | 10 | 184,588 |
Yes | output | 1 | 92,294 | 10 | 184,589 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A robber has attempted to rob a bank but failed to complete his task. However, he had managed to open all the safes.
Oleg the bank client loves money (who doesn't), and decides to take advantag... | instruction | 0 | 92,295 | 10 | 184,590 |
No | output | 1 | 92,295 | 10 | 184,591 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A robber has attempted to rob a bank but failed to complete his task. However, he had managed to open all the safes.
Oleg the bank client loves money (who doesn't), and decides to take advantag... | instruction | 0 | 92,296 | 10 | 184,592 |
No | output | 1 | 92,296 | 10 | 184,593 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A robber has attempted to rob a bank but failed to complete his task. However, he had managed to open all the safes.
Oleg the bank client loves money (who doesn't), and decides to take advantag... | instruction | 0 | 92,297 | 10 | 184,594 |
No | output | 1 | 92,297 | 10 | 184,595 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A robber has attempted to rob a bank but failed to complete his task. However, he had managed to open all the safes.
Oleg the bank client loves money (who doesn't), and decides to take advantag... | instruction | 0 | 92,298 | 10 | 184,596 |
No | output | 1 | 92,298 | 10 | 184,597 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A conglomerate consists of n companies. To make managing easier, their owners have decided to merge all companies into one. By law, it is only possible to merge two companies, so the owners plan to select two companies, merge them into one, ... | instruction | 0 | 92,645 | 10 | 185,290 |
Tags: greedy
Correct Solution:
```
def func(inpstr):
return inpstr[0]
N = int(input())
arr = []
money = 0
for i in range(N):
a = [int(i) for i in input().split()]
arr.append([max(a[1::])] + [a[0]])
arr.sort(key = func)
while(len(arr) != 1):
p = arr[-2][1]
m = arr[-1][0] - arr[-2][0]
mon... | output | 1 | 92,645 | 10 | 185,291 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A conglomerate consists of n companies. To make managing easier, their owners have decided to merge all companies into one. By law, it is only possible to merge two companies, so the owners plan to select two companies, merge them into one, ... | instruction | 0 | 92,646 | 10 | 185,292 |
Tags: greedy
Correct Solution:
```
n=int(input())
a=[]
b=[]
for i in range (n):
s=list (map (int, input().strip().split()))
a.append(s.pop(0))
b.append(max(s))
c=max(b)
sum = 0
for i in range(n):
sum+=(c-b[i])*a[i]
print(sum)
``` | output | 1 | 92,646 | 10 | 185,293 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A conglomerate consists of n companies. To make managing easier, their owners have decided to merge all companies into one. By law, it is only possible to merge two companies, so the owners plan to select two companies, merge them into one, ... | instruction | 0 | 92,647 | 10 | 185,294 |
Tags: greedy
Correct Solution:
```
n = int(input())
CompS = []
S = 0
for i in range(n):
m, *H = list(map(int, input().split()))
Max = max(H)
CompS.append((Max, m))
CompS.sort(reverse=True)
for i in range(1, len(CompS)):
S += (CompS[0][0] - CompS[i][0]) * CompS[i][1]
print(S)
``` | output | 1 | 92,647 | 10 | 185,295 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A conglomerate consists of n companies. To make managing easier, their owners have decided to merge all companies into one. By law, it is only possible to merge two companies, so the owners plan to select two companies, merge them into one, ... | instruction | 0 | 92,648 | 10 | 185,296 |
Tags: greedy
Correct Solution:
```
n = int(input())
b = [int(x) for x in input().split()]
q = b[0]
p = max(b[1:])
total = 0
for i in range(n-1):
a = [int(x) for x in input().split()]
c = a[0]
m = max(a[1:])
if p > m:
total += c * (p - m)
elif m > p:
total += q * (m - p)
p = m... | output | 1 | 92,648 | 10 | 185,297 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A conglomerate consists of n companies. To make managing easier, their owners have decided to merge all companies into one. By law, it is only possible to merge two companies, so the owners plan to select two companies, merge them into one, ... | instruction | 0 | 92,649 | 10 | 185,298 |
Tags: greedy
Correct Solution:
```
from sys import stdin, stdout
input = stdin.readline
n = (int)(input())
a,s,t =[],0,[]
for i in range(n):
b = list(map(int,input().split()))
a.append(max(b[1:]))
t.append(b[0])
boro = max(a)
for i in range(n):
s+=(boro-a[i])*t[i]
stdout.write(str(s))
``` | output | 1 | 92,649 | 10 | 185,299 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A conglomerate consists of n companies. To make managing easier, their owners have decided to merge all companies into one. By law, it is only possible to merge two companies, so the owners plan to select two companies, merge them into one, ... | instruction | 0 | 92,650 | 10 | 185,300 |
Tags: greedy
Correct Solution:
```
import sys
input=sys.stdin.readline
N=int(input())
tot=[]
for i in range(N):
x=list(map(int,input().split()))
maxim=max(x[1:])
n=x[0]
tot.append((maxim,n))
tot.sort()
counter=0
summa=tot[0][1]
for i in range(1,len(tot)):
counter+=(tot[i][0]-tot[i-1][0])*summa
s... | output | 1 | 92,650 | 10 | 185,301 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.