LTNightshade

Untitled

Jan 21st, 2021
901
142 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const speed = parseInt(readline());
  2. const lightCount = parseInt(readline());
  3. const isGreen = (sp, tl) => Math.floor(Math.round(tl.distance / (sp * 1000 / 3600)) / tl.duration) % 2 == 0;
  4. let s = [];
  5.  
  6. for (let i = 0; i < lightCount; i++) {
  7.     var [distance, duration] = readline().split(' ').map(i => parseInt(i));
  8.     s.push({ duration, distance });
  9. }
  10.  
  11. for (let as = speed; as > 0; as--) {
  12.     if (s.every(tl => isGreen(as, tl))) {
  13.         console.log(as);
  14.         break;
  15.     }
  16. }
RAW Paste Data