Submission #7354413


Source Code Expand

Copy
#include <bits/stdc++.h>

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

signed main() {
  ll N;
  cin >> N;
  vector<pair<long double, long double>> p(N);
  rep(i,N)
    cin >> p[i].first >> p[i].second;

  sort(begin(p), end(p), [](const auto &l, const auto &r) {
        auto lv = atan2l(l.second, l.first);   
        auto rv = atan2l(r.second, r.first);   
        return lv < rv;
      });

  rep(i, N) {
    p.push_back(p[i]);
  }

  double ans = 0.0;
  rep(i, N) {
    double curx = 0, cury = 0;
    for (int j=i; j<i+N; j++) {
      curx += p[j].first;
      cury += p[j].second;
      ans = max(ans, curx*curx + cury*cury);
    }
  }
  printf("%.20f\n", sqrt(ans));
  return 0;
}

Submission Info

Submission Time
Task F - Engines
User bobuhiro11
Language C++14 (GCC 5.4.1)
Score 600
Code Size 878 Byte
Status
Exec Time 1 ms
Memory 256 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 00-sample-01.txt, 00-sample-02.txt, 00-sample-03.txt, 00-sample-04.txt, 00-sample-05.txt, 00-sample-06.txt, 00-sample-07.txt
All 600 / 600 00-sample-01.txt, 00-sample-02.txt, 00-sample-03.txt, 00-sample-04.txt, 00-sample-05.txt, 00-sample-06.txt, 00-sample-07.txt, 01-random-very-small-01.txt, 01-random-very-small-02.txt, 01-random-very-small-03.txt, 02-random-small-01.txt, 02-random-small-02.txt, 02-random-small-03.txt, 03-random-01.txt, 03-random-02.txt, 03-random-03.txt, 04-zero-01.txt, 05-same-01.txt, 05-same-02.txt, 06-linear-01.txt, 06-linear-02.txt, 06-linear-03.txt, 07-linear-positive-01.txt, 07-linear-positive-02.txt, 07-linear-positive-03.txt, 08-90-degree-01.txt, 08-90-degree-02.txt, 09-180-degree-01.txt, 09-180-degree-02.txt, 10-sandglass-01.txt, 10-sandglass-02.txt, 11-circle-01.txt, 11-circle-02.txt, 11-circle-03.txt, 11-circle-04.txt, 11-circle-05.txt, 12-square-01.txt, 12-square-02.txt, 12-square-03.txt, 13-corner-01.txt, 13-corner-02.txt
Case Name Status Exec Time Memory
00-sample-01.txt 1 ms 256 KB
00-sample-02.txt 1 ms 256 KB
00-sample-03.txt 1 ms 256 KB
00-sample-04.txt 1 ms 256 KB
00-sample-05.txt 1 ms 256 KB
00-sample-06.txt 1 ms 256 KB
00-sample-07.txt 1 ms 256 KB
01-random-very-small-01.txt 1 ms 256 KB
01-random-very-small-02.txt 1 ms 256 KB
01-random-very-small-03.txt 1 ms 256 KB
02-random-small-01.txt 1 ms 256 KB
02-random-small-02.txt 1 ms 256 KB
02-random-small-03.txt 1 ms 256 KB
03-random-01.txt 1 ms 256 KB
03-random-02.txt 1 ms 256 KB
03-random-03.txt 1 ms 256 KB
04-zero-01.txt 1 ms 256 KB
05-same-01.txt 1 ms 256 KB
05-same-02.txt 1 ms 256 KB
06-linear-01.txt 1 ms 256 KB
06-linear-02.txt 1 ms 256 KB
06-linear-03.txt 1 ms 256 KB
07-linear-positive-01.txt 1 ms 256 KB
07-linear-positive-02.txt 1 ms 256 KB
07-linear-positive-03.txt 1 ms 256 KB
08-90-degree-01.txt 1 ms 256 KB
08-90-degree-02.txt 1 ms 256 KB
09-180-degree-01.txt 1 ms 256 KB
09-180-degree-02.txt 1 ms 256 KB
10-sandglass-01.txt 1 ms 256 KB
10-sandglass-02.txt 1 ms 256 KB
11-circle-01.txt 1 ms 256 KB
11-circle-02.txt 1 ms 256 KB
11-circle-03.txt 1 ms 256 KB
11-circle-04.txt 1 ms 256 KB
11-circle-05.txt 1 ms 256 KB
12-square-01.txt 1 ms 256 KB
12-square-02.txt 1 ms 256 KB
12-square-03.txt 1 ms 256 KB
13-corner-01.txt 1 ms 256 KB
13-corner-02.txt 1 ms 256 KB