시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
2 초 128 MB 2631 487 324 18.815%

문제

N명의 아이들이 한 줄로 줄을 서서 놀이공원에서 1인승 놀이기구를 기다리고 있다. 이 놀이공원에는 총 M종류의 1인승 놀이기구가 있으며, 1번부터 M번까지 번호가 매겨져 있다.

모든 놀이기구는 각각 정해진 운행 시간이 정해져 있어서, 운행 시간이 지나면 탑승하고 있던 아이는 내리게 된다. 놀이 기구가 비어 있으면 현재 줄에서 가장 앞에 서 있는 아이가 빈 놀이기구에 탑승한다. 만일 여러 개의 놀이기구가 동시에 비어 있으면, 더 작은 번호가 적혀 있는 놀이기구를 먼저 탑승한다고 한다.

놀이기구가 모두 비어 있는 상태에서 첫 번째 아이가 놀이기구에 탑승한다고 할 때, 줄의 마지막 아이가 타게 되는 놀이기구의 번호를 구하는 프로그램을 작성하시오.

입력

첫째 줄에 N(1<= N<= 2,000,000,000)과 M(1<= M<= 10,000)이 빈칸을 사이에 두고 주어진다. 둘째 줄에는 각 놀이기구의 운행 시간을 나타내는 M개의 자연수가 순서대로 주어진다. 운행 시간은 1 이상 30 이하의 자연수이며, 단위는 분이다.

출력

첫째 줄에 마지막 아이가 타게 되는 놀이기구의 번호를 출력한다.

예제 입력 1

22 5
1 2 3 4 5

예제 출력 1

4

힌트

W3sicHJvYmxlbV9pZCI6IjE1NjEiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWIxODBcdWM3NzQgXHVhY2Y1XHVjNmQwIiwiZGVzY3JpcHRpb24iOiI8cD5OXHViYTg1XHVjNzU4IFx1YzU0NFx1Yzc3NFx1YjRlNFx1Yzc3NCBcdWQ1NWMgXHVjOTA0XHViODVjIFx1YzkwNFx1Yzc0NCBcdWMxMWNcdWMxMWMgXHViMTgwXHVjNzc0XHVhY2Y1XHVjNmQwXHVjNWQwXHVjMTFjIDFcdWM3NzhcdWMyYjkgXHViMTgwXHVjNzc0XHVhZTMwXHVhZDZjXHViOTdjIFx1YWUzMF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MTAwMDAuJm5ic3A7PFwvcD5cclxuXHJcbjxwPlRoZSBuZXh0IGxpbmUgY29uc2lzdHMgb2YgTSBpbnRlZ2VycyBzZXBhcmF0ZWQgYnkgd2hpdGVzcGFjZXMuIFRoZXNlIGludGVnZXJzIHJlcHJlc2VudCBkdXJhdGlvbnMgb2YgcmlkZXMgZm9yIGVhY2ggb2YgTSBjYXJzIGdpdmVuIGluIG1pbnV0ZXMuIEVhY2ggb2YgdGhlc2UgbnVtYmVycyB3aWxsIGJlIG5vdCBsZXNzIHRoYW4gMSBhbmQgbm90IGdyZWF0ZXIgdGhhbiAzMC48XC9wPlxyXG4iLCJvdXRwdXQiOiI8cD5UaGUgZmlyc3QgYW5kIHRoZSBvbmx5IGxpbmUgb2YgdGhlIG91dHB1dCBmaWxlIHNob3VsZCBjb250YWluIHRoZSBudW1iZXIgb2YgdGhlIGNhciBhcyBkZWZpbmVkIGFib3ZlLiZuYnNwOzxcL3A+XHJcblxyXG48cD4mbmJzcDs8XC9wPlxyXG4iLCJoaW50IjoiIiwib3JpZ2luYWwiOiIxIiwicHJvYmxlbV9sYW5nX2NvZGUiOiJcdWM2MDFcdWM1YjQifV0=

출처

Olympiad > Croatian Highschool Competitions in Informatics > 2003 > Regional Competition - Seniors 3번

  • 문제를 번역한 사람: author5
  • 문제의 오타를 찾은 사람: djm03178
  • 잘못된 조건을 찾은 사람: doju