Logo
(追記) (追記ここまで)

16849번 - Craziness 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB66352852.830%

문제

When you ask anyone about their family after a major gathering (e.g., for any kind of holidays), they will typically tell you how crazy their family is.1 Somehow, years of knowing each other — and probably genetic similarity — mean that family members know exactly how to egg each other on or exasperate each other. Somehow, when put in the same room, a group of normal quiet people suddenly become insanely wild. Here, you will calculate which family members to invite to maximize the total craziness.

For each pair of family members i, j, you will be given a (positive or negative) number ci,j, which is how much craziness this pair will contribute if both are invited; negative numbers mean that this pair will actually calm things down. The goal is to find the non-empty (i.e., at least one person must be invited) subset to invite to achieve maximum total craziness, which is the sum of crazinesses over all pairs of invited family members, plus the individual crazinesses of all guests.

1If you asked salmon why they swim up rivers for weeks, they’d probably tell you: “I can’t miss that party — my salmon family is crazy, man!!!”

입력

The first line contains a number K ≥ 1, which is the number of input data sets in the file. This is followed by K data sets of the following form:

The first line of a data set contains the number 2 ≤ n ≤ 20 of relatives to choose from. This is followed by n lines, each with n doubles −1000.0 ≤ ci,j ≤ 1000.0. ci,j is the craziness added when you invite both i and j. We promise you that ci,j = cj,i for all i and j. ci,i is the craziness that person i himself/herself contributes.

출력

For each data set, first output “Data Set x:” on a line by itself, where x is its number. Then, output the maximum total craziness you can get by inviting a non-empty subset of these relatives, rounded to two decimals.

제한

예제 입력 1

1
5
1 -2.1 1.5 -10.3 4.7
-2.1 0 -8.1 2.3 5.0
1.5 -8.1 1.5 1.0 0.5
-10.3 2.3 1.0 -1 15.4
4.7 5.0 0.5 15.4 -2

예제 출력 1

Data Set 1:
19.70

힌트

출처

University > The USC Programming Contest > Fall 2018: Family C번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /