Submission #60981923


Source Code Expand

#include <bits/stdc++.h>
#define st first
#define nd second
#define db double
#define re register
#define pb push_back
#define mk make_pair
#define int long long
#define pii pair<int, int>
#define ull unsigned long long
#define mst(a, b) memset(a, b, sizeof(a))
using namespace std;
const int N = 3e5 + 10, INF = 1e9 + 1, mod = 998244353;
inline int read()
{ 
  int s = 0, w = 1;
  char ch = getchar();
  while(ch < '0' || ch > '9') { if(ch == '-') w *= -1; ch = getchar(); }
  while(ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
  return s * w;
}
int n;
db ans, X, H;
bool flag;
signed main()
{
  n = read();
  X = read(), H = read();
  for(re int i = 2, x, h; i <= n; i++){
    x = read(), h = read();
    db k = (H - ans) / X; //斜率 y = kx + ans
    db y = k * x + ans;
    if(h != y) flag = true;
    if(h >= y) X = x, H = h;
    else ans = (h * X - H * x) / (X - x);
  }
  if(flag && !ans) cout << "-1\n";
  else printf("%.10lf\n", ans);
  return 0;
}

Submission Info

Submission Time
Task F - Visible Buildings
User Booksnow
Language C++ 20 (gcc 12.2)
Score 0
Code Size 1015 Byte
Status WA
Exec Time 13 ms
Memory 3836 KiB

Compile Error

Main.cpp: In function ‘int main()’:
Main.cpp:29:14: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   29 |   for(re int i = 2, x, h; i <= n; i++){
      |              ^
Main.cpp:29:21: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   29 |   for(re int i = 2, x, h; i <= n; i++){
      |                     ^
Main.cpp:29:24: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   29 |   for(re int i = 2, x, h; i <= n; i++){
      |                        ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 525
Status
AC × 4
AC × 23
WA × 4
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
All hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
Case Name Status Exec Time Memory
hand_01.txt WA 1 ms 3756 KiB
hand_02.txt AC 1 ms 3504 KiB
hand_03.txt AC 1 ms 3816 KiB
hand_04.txt WA 1 ms 3756 KiB
random_01.txt AC 13 ms 3836 KiB
random_02.txt AC 10 ms 3756 KiB
random_03.txt AC 8 ms 3832 KiB
random_04.txt AC 5 ms 3620 KiB
random_05.txt AC 10 ms 3728 KiB
random_06.txt AC 5 ms 3688 KiB
random_07.txt AC 3 ms 3688 KiB
random_08.txt AC 7 ms 3692 KiB
random_09.txt AC 2 ms 3748 KiB
random_10.txt AC 4 ms 3680 KiB
random_11.txt AC 9 ms 3688 KiB
random_12.txt AC 6 ms 3692 KiB
random_13.txt AC 2 ms 3712 KiB
random_14.txt AC 3 ms 3752 KiB
random_15.txt AC 10 ms 3812 KiB
random_16.txt AC 8 ms 3656 KiB
random_17.txt WA 6 ms 3720 KiB
random_18.txt AC 10 ms 3712 KiB
random_19.txt WA 7 ms 3748 KiB
sample_01.txt AC 1 ms 3752 KiB
sample_02.txt AC 1 ms 3452 KiB
sample_03.txt AC 1 ms 3688 KiB
sample_04.txt AC 1 ms 3676 KiB