Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const speed = parseInt(readline());
- const lightCount = parseInt(readline());
- const isGreen = (sp, tl) => Math.floor(Math.round(tl.distance / (sp * 1000 / 3600)) / tl.duration) % 2 == 0;
- let s = [];
- for (let i = 0; i < lightCount; i++) {
- var [distance, duration] = readline().split(' ').map(i => parseInt(i));
- s.push({ duration, distance });
- }
- for (let as = speed; as > 0; as--) {
- if (s.every(tl => isGreen(as, tl))) {
- console.log(as);
- break;
- }
- }
RAW Paste Data