結果
問題 | No.1046 Fruits Rush |
ユーザー |
|
提出日時 | 2020-05-08 22:46:37 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 153 ms / 2,000 ms |
コード長 | 1,599 bytes |
コンパイル時間 | 258 ms |
コンパイル使用メモリ | 82,524 KB |
実行使用メモリ | 91,064 KB |
最終ジャッジ日時 | 2024-07-04 01:03:40 |
合計ジャッジ時間 | 3,721 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 14 |
ソースコード
from __future__ import print_functionimport syssys.setrecursionlimit(500000)import reimport arrayimport copyimport functoolsimport operatorimport mathimport stringimport fractionsfrom fractions import Fractionimport collectionsimport itertoolsimport bisectimport randomimport timeimport heapqfrom heapq import heappushfrom heapq import heappopfrom heapq import heappushpopfrom heapq import heapifyfrom heapq import heapreplacefrom queue import PriorityQueue as pqfrom queue import Queuefrom itertools import accumulatefrom collections import dequefrom collections import Counterfrom operator import mulfrom functools import reduceinput = sys.stdin.readlinedef eprint(*args, **kwargs):print(*args, file=sys.stderr, **kwargs)return# from fractions import gcd# from math import gcd# def lcm(n, m):# return int(n * m / gcd(n, m))# def coprimize(p, q):# common = gcd(p, q)# return (p // common, q // common)# def find_gcd(list_l):# x = reduce(gcd, list_l)# return xdef combinations_count(n, r):r = min(r, n - r)numer = reduce(mul, range(n, n - r, -1), 1)denom = reduce(mul, range(1, r + 1), 1)return numer // denomdef main():n,k = map(int,input().strip().split())a = list(map(int, input().strip().split()))# a = list(map(lambda x: int(x) if int(x)>=0 else 0, input().strip().split()))a.sort(reverse=True)# eprint(a)sumx=0for i in range(k):if a[i]>0 or i==0:sumx+=a[i]print(sumx)if __name__ == '__main__':main()