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

19748번 - Schedule 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB211100.000%

문제

Anton goes to school from Monday to Friday. At Anton's school lessons last for 45ドル$ minutes and breaks for 15ドル$ minutes. The first lesson starts at 7ドル$ a.m. and the last lesson finishes at 3:45 p.m. It's easy to see that each lesson starts at the beginning of an hour

Anton wants to stay healthy, so he wants to sleep for 8ドル$ hours every day. He doesn't always get it, because lessons can start at 7ドル$ a.m. Therefore, to sleep in average 8 hours a day on other days he can sleep more than 8ドル$ hours, for example, on Saturday and Sunday, when he doesn't go to school. Anton can't sleep more than 10ドル$ hours a day, because otherwise he will feel that he has slept too much and the rest of the day will feel bad. Anton gets up at least an hour before the beginning of the lessons to have a breakfast and get to school. Anton falls asleep at midnight every day.

Anton is a good student, so he wants to be at all lessons in his school. But if one day at a time when he needs to get up to go to school, he has a lack of sleep for at least 5ドル$ hours, he will oversleep his first lesson. Anton started to go to school on Monday. Initially Anton he has no lack of sleep, because in summer he had time to rest and sleep.

Help Anton to find out what day he will oversleep his first lesson.

입력

The first line contains $k$ --- the number of lack of sleep hours that Anton needs to oversleep his first lesson. (1ドル \le k \le 1000$)

Next five lines contain 9ドル$ symbols 0ドル$ and 1ドル$ characters --- a description of the Anton's school schedule from Monday to Friday. On Saturday and Sunday Anton doesn't go to school. If on the day $i$ Anton has a lesson with the number $j,ドル then $j$-th character in the $i$-th row is 1ドル$ otherwise it is 0ドル$.

출력

If Anton never has lack of sleep and never oversleeps his lessons, output <<-1>>, otherwise output two integers --- number of week and day when Anton will skip his first lesson.

제한

예제 입력 1

11
111111100
111111100
111111100
111111100
111111100

예제 출력 1

2 3

힌트

Every day Anton's lessons last from 7:00 a.m. to 1:45 p.m., so every day he will get up at 6ドル$ a.m. and accumulate 2ドル$ hours of lack of sleep. By the weekend Anton will accumulate 10ドル$ hours of lack of sleep, but he will be able to compensate for 4ドル$ of them, if he sleeps 10ドル$ hours on Saturday and Sunday. Starting the second week with 6ドル$ hours of lack of sleep, on Wednesday Anton will overspleep his first lesson.

출처

Olympiad > Russian Olympiad in Informatics > Russia High School Programming Contest > Russia High School Programming Contest 2017 H번

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

출처

대학교 대회

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

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