시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 6301 2575 1747 39.822%

문제

N개의 숫자로 구분된 각각의 마을에 한 명의 학생이 살고 있다.

어느 날 이 N명의 학생이 X (1 ≤ X ≤ N)번 마을에 모여서 파티를 벌이기로 했다. 이 마을 사이에는 총 M개의 단방향 도로들이 있고 i번째 길을 지나는데 Ti(1 ≤ Ti ≤ 100)의 시간을 소비한다.

각각의 학생들은 파티에 참석하기 위해 걸어가서 다시 그들의 마을로 돌아와야 한다. 하지만 이 학생들은 워낙 게을러서 최단 시간에 오고 가기를 원한다.

이 도로들은 단방향이기 때문에 아마 그들이 오고 가는 길이 다를지도 모른다. N명의 학생들 중 오고 가는데 가장 많은 시간을 소비하는 학생은 누구일지 구하여라.

입력

첫째 줄에 N(1 <= N <= 1,000), M(1 <= M <= 10,000), X가 공백으로 구분되어 입력된다. 두 번째 줄부터 M+1번째 줄까지 i번째 도로의 시작점, 끝점, 그리고 이 도로를 지나는데 필요한 소요시간 Ti가 들어온다.

모든 학생들은 집에서 X에 갈수 있고, X에서 집으로 돌아올 수 있는 데이터만 입력으로 주어진다.

출력

첫 번째 줄에 N명의 학생들 중 오고 가는데 가장 오래 걸리는 학생의 소요시간을 출력한다.

예제 입력 1

4 8 2
1 2 4
1 3 2
1 4 7
2 1 1
2 3 5
3 1 2
3 4 4
4 2 3

예제 출력 1

10
W3sicHJvYmxlbV9pZCI6IjEyMzgiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWQzMGNcdWQyZjAiLCJkZXNjcmlwdGlvbiI6IjxwPk5cdWFjMWNcdWM3NTggXHVjMjJiXHVjNzkwXHViODVjIFx1YWQ2Y1x1YmQ4NFx1YjQxYyBcdWFjMDFcdWFjMDFcdWM3NTggXHViOWM4XHVjNzQ0XHVjNWQwIFx1ZDU1YyBcdWJhODVcdWM3NTggXHVkNTU5XHVjMGRkXHVjNzc0IFx1YzBiNFx1YWNlMCBcdWM3ODhcdWIyZTQ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lIGxvbmdlc3QgYW1vdW50IG9mIHRpbWUgYSBjb3cgbXVzdCBzcGVuZCB3YWxraW5nIHRvIHRoZSBwYXJ0eSBhbmQgYmFjaz88XC9wPlxyXG4iLCJpbnB1dCI6IjxwPiogTGluZSAxOiBUaHJlZSBzcGFjZS1zZXBhcmF0ZWQgaW50ZWdlcnMsIHJlc3BlY3RpdmVseTogTiwgTSwgYW5kIFg8XC9wPlxyXG5cclxuPHA+KiBMaW5lcyAyLi5NKzE6IExpbmUgaSsxIGRlc2NyaWJlcyByb2FkIGkgd2l0aCB0aHJlZSBzcGFjZS1zZXBhcmF0ZWQgaW50ZWdlcnM6IEFpLCBCaSwgYW5kIFRpLiBUaGUgZGVzY3JpYmVkIHJvYWQgcnVucyBmcm9tIGZhcm0gQWkgdG8gZmFybSBCaSwgcmVxdWlyaW5nIFRpIHRpbWUgdW5pdHMgdG8gdHJhdmVyc2UuPFwvcD5cclxuIiwib3V0cHV0IjoiPHA+KiBMaW5lIDE6IE9uZSBpbnRlZ2VyOiB0aGUgbWF4aW11bSBvZiB0aW1lIGFueSBvbmUgY293IG11c3Qgd2Fsay48XC9wPlxyXG5cclxuPHA+Jm5ic3A7PFwvcD5cclxuIiwiaGludCI6IiIsIm9yaWdpbmFsIjoiMSIsInByb2JsZW1fbGFuZ19jb2RlIjoiXHVjNjAxXHVjNWI0In1d

출처

Olympiad > USA Computing Olympiad > 2006-2007 Season > USACO February 2007 Contest > Silver 3번

  • 문제를 번역한 사람: author6
  • 빠진 조건을 찾은 사람: his130