Submission #1607745


Source Code Expand

#include <bits/stdc++.h>

using namespace std;

int main(void) {
  int n;
  cin >> n;

  int s, g;
  cin >> s >> g;

  vector<int> l(n + 1), r(n + 1);
  for (int i = 0; i <= n; i++) {
    cin >> l[i] >> r[i];
  }

  int pos = s, cnt = 1;
  double ans = 0.0;
  for (int i = 1; i < n; i++) {
    if (l[i] <= pos && pos <= r[i]) {
      cnt++;
    } else if (pos < l[i]) {
      ans += hypot(l[i] - pos, cnt);
      pos = l[i];
      cnt = 1;
    } else if (pos > r[i]) {      
      ans += hypot(pos - r[i], cnt);
      pos = r[i];
      cnt = 1;
    }
  }
  ans += hypot(g - pos, cnt);

  printf("%.12f\n", ans);

  return 0;
}

Submission Info

Submission Time
Task D - レースゲーム
User legosuke
Language C++14 (GCC 5.4.1)
Score 0
Code Size 662 Byte
Status WA
Exec Time 126 ms
Memory 1792 KB

Judge Result

Set Name All
Score / Max Score 0 / 100
Status
AC × 23
WA × 3
Set Name Test Cases
All 00_sample1.txt, 00_sample2.txt, 01_rnd_large_00.txt, 01_rnd_large_01.txt, 01_rnd_large_02.txt, 01_rnd_small_00.txt, 01_rnd_small_01.txt, 01_rnd_small_02.txt, 02_narrowrnd_large_00.txt, 02_narrowrnd_large_01.txt, 02_narrowrnd_small_00.txt, 02_narrowrnd_small_01.txt, 03_zigzag_large_00.txt, 03_zigzag_small_00.txt, 04_middle_large_00.txt, 04_middle_large_01.txt, 04_middle_large_02.txt, 04_middle_small_00.txt, 04_middle_small_01.txt, 04_middle_small_02.txt, 05_turnleft_large_00.txt, 05_turnleft_small_00.txt, 06_turnright_large_00.txt, 06_turnright_small_00.txt, 07_free_large_00.txt, 07_free_small_00.txt
Case Name Status Exec Time Memory
00_sample1.txt AC 2 ms 512 KB
00_sample2.txt AC 1 ms 256 KB
01_rnd_large_00.txt AC 126 ms 1792 KB
01_rnd_large_01.txt AC 125 ms 1792 KB
01_rnd_large_02.txt AC 124 ms 1792 KB
01_rnd_small_00.txt AC 2 ms 256 KB
01_rnd_small_01.txt AC 2 ms 256 KB
01_rnd_small_02.txt AC 2 ms 256 KB
02_narrowrnd_large_00.txt AC 124 ms 1792 KB
02_narrowrnd_large_01.txt AC 125 ms 1792 KB
02_narrowrnd_small_00.txt AC 2 ms 256 KB
02_narrowrnd_small_01.txt AC 2 ms 256 KB
03_zigzag_large_00.txt AC 100 ms 1792 KB
03_zigzag_small_00.txt AC 2 ms 256 KB
04_middle_large_00.txt AC 126 ms 1792 KB
04_middle_large_01.txt AC 125 ms 1792 KB
04_middle_large_02.txt AC 125 ms 1792 KB
04_middle_small_00.txt AC 2 ms 256 KB
04_middle_small_01.txt AC 2 ms 256 KB
04_middle_small_02.txt AC 2 ms 256 KB
05_turnleft_large_00.txt WA 125 ms 1792 KB
05_turnleft_small_00.txt WA 2 ms 256 KB
06_turnright_large_00.txt WA 124 ms 1792 KB
06_turnright_small_00.txt AC 2 ms 256 KB
07_free_large_00.txt AC 103 ms 1792 KB
07_free_small_00.txt AC 2 ms 256 KB