====== 슬라임 합치기 ====== ===== 풀이 ===== * 어떤 순서대로 합치든 답이 일정한 것을 쉽게 확인할수 있다. * 그러므로 그냥 앞에서부터 합쳐서 얻은 값을 출력하면 된다. 시간복잡도는 O(n) ===== 코드 ===== """Solution code for "BOJ 14241. 슬라임 합치기". - Problem link: https://www.acmicpc.net/problem/14241 - Solution link: http://www.teferi.net/ps/problems/boj/14241 Tags: [ad hoc] """ def main(): _N = int(input()) slimes = [int(x) for x in input().split()] answer = 0 size = 0 for s in slimes: answer += size * s size += s print(answer) if __name__ == '__main__': main() {{tag>BOJ ps:problems:boj:실버_3}}