루미 알고리즘

#1624실버Programmeringsolympiaden's Budget

PO 2025 온라인 예선코딩출제 Joshua Andersson영어 원문이 문제가 어렵다면 — 배우는 순서 보기

영어 원문입니다. 원문의 수식·표를 글자로 옮겨 모양이 다를 수 있습니다. 정확한 내용은 원문 페이지에서 확인하세요. 원문 페이지 열기 (새 창)

Problem

Programmeringsolympiaden (PO) must write a budget every year, which then needs to be approved by the treasurer Emil. This year, the PO leadership has proposed some rather wild ideas, such as buying 2000 ducks and purchasing a PO-yacht to sail to the IOI (the world finals of competitive programming). Emil finds it difficult to determine whether the budget is reasonable or not.

A budget consists of several revenues and expenses. To assess whether the budget is reasonable, Emil wants to calculate whether the proposed budget would result in Programmeringsolympiaden making a profit, a loss, or breaking even financially. Can you write a program to help Emil decide this?

Input

The first line of input contains the integer N (1 ≤ N ≤ 30), the number of revenues/expenses in the budget.

This is followed by all N revenues/expenses. Each is described over two lines: first, a description of what it is, a string of at most 30 characters. For simplicity, the string contains no spaces. The next line contains an integer K (-10^7 ≤ K ≤ 10^7). If K is positive, it represents a revenue of K kronor; otherwise, it is an expense of -K kronor.

Output

  • If the budget would lead to PO making money, print “Usch, vinst”. This translates to “Ew, profit”.
  • If the budget breaks even, print “Lagom”. This translates to “Just right”.
  • If the budget would lead to a loss, print “Nekad”. This translates to “Denied”.

Note that you should not print the quotation marks.

Scoring

Your solution will be tested on a set of test groups, each worth a number of points. Each test group contains a set of test cases. To get the points for a test group you need to solve all test cases in the test group.

GroupPointsConstraints
120K = 0 for all K.
230K ≥ 0 for all K.
350No additional constraints.

Explanation of Sample 1

Since the yacht costs much more than what PO receives from the sponsorship, the budget results in a loss, and thus the correct answer is Nekad.

Explanation of Sample 2

Even though there are some expenses, their total is less than the revenue from the sponsorship.

Explanation of Sample 3

If there is no PO at all, there are neither revenues nor expenses, which results in breaking even.

Explanation of Sample 4

Here, the revenues exactly match the expenses, which also results in breaking even.

예제

예제 1

입력
2
sponsring
70000
PO_yacht
-1000000
출력
Nekad

예제 2

입력
4
sponsring
70000
2000_ankor
-5000
Lite_fika
-1000
500_affischer
-10000
출력
Usch, vinst

예제 3

입력
1
inget_PO
0
출력
Lagom

예제 4

입력
2
sponsring
70000
final
-70000
출력
Lagom

출처 표기

출처: Programmeringsolympiaden 2025년 온라인 예선 · 원문 페이지 · 이용 조건 CC BY-SA · LaTeX 원문을 화면용 글로 옮겼습니다(수식·표의 모양이 다를 수 있습니다). 내용은 고치지 않았습니다.

크리에이티브 커먼즈 저작자표시-동일조건변경허락.

문제 출처: 한국정보올림피아드(KOI) (CC BY-NC-SA 4.0) · International Olympiad in Informatics (IOI) (CC BY) · Centre for Education in Mathematics and Computing (CEMC), University of Waterloo (CC BY-NC 4.0) · Programmeringsolympiaden (CC BY-SA) · CSES Problem Set (Antti Laaksonen) (CC BY-NC-SA 4.0). 루미 알고리즘은 위 단체들과 관계없는 별도의 서비스이며, 자료는 원문 그대로 싣습니다. 문제마다 출처와 이용 조건을 따로 표기합니다.