Submission #633263

# Submission time Handle Problem Language Result Execution time Memory
633263 2022-08-22T02:50:58 Z afatpotato Mobile (BOI12_mobile) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;


pair<long long, long long> tower[1000000];
long long n, l;

int main() {
    cin >> n >> l;
    tower.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> tower[i].first >> tower[i].second;
    }
    sort(tower.begin(), tower.end());
    double low = 0;
    double high = 1.5e9;

    while (high - low > 1e-3) {
        double mid = (low + high) / 2;
        double cur = 0;
        for (int i = 0; i < n; i++) {
            double delta = sqrt(mid * mid - tower[i].second * tower[i].second);
            double a = tower[i].first - delta;
            double b = tower[i].first + delta;
            if (a <= cur) {
                cur = max(cur, b);
            }
        }
        if (cur >= l) {
            high = mid;
        } else {
            low = mid;
        }
    }
    cout << fixed;
    cout << setprecision(4);
    cout << low << endl;
}

Compilation message

mobile.cpp: In function 'int main()':
mobile.cpp:11:11: error: request for member 'resize' in 'tower', which is of non-class type 'std::pair<long long int, long long int> [1000000]'
   11 |     tower.resize(n);
      |           ^~~~~~
mobile.cpp:15:16: error: request for member 'begin' in 'tower', which is of non-class type 'std::pair<long long int, long long int> [1000000]'
   15 |     sort(tower.begin(), tower.end());
      |                ^~~~~
mobile.cpp:15:31: error: request for member 'end' in 'tower', which is of non-class type 'std::pair<long long int, long long int> [1000000]'
   15 |     sort(tower.begin(), tower.end());
      |                               ^~~