ソースコード 拡げる

Copy
```#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
const double EPS = 1e-8, INF = 1e12, PI = 2 * acos(0.0);
typedef complex<double> P;
namespace std {
bool operator < (const P& a, const P& b) { return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b); }
bool operator == (const P& a, const P& b) { return abs(real(a) - real(b)) < EPS && abs(imag(a) - imag(b)) < EPS; }
P operator / (const P& a, const double& b) { return P(real(a) / b, imag(a) / b); }
P operator * (const P& a, const double& b) { return P(real(a) * b, imag(a) * b); }
}
double argument(const P &a, const P &b) { // argument for A->B[-PI,PI]
double ax = real(a), ay = imag(a), bx = real(b), by = imag(b);
return atan2(by - ay, bx - ax);
}
/*---------------------------------------------------------------------------------------------------
∧＿∧
∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
（ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
／　　　＼　 　  |　|
/　　 /￣￣￣￣/　　|
＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/

int N;
//---------------------------------------------------------------------------------------------------
void _main()
{
cin >> N;
vector<P> v;
rep(i, 0, N)
{
int x, y;
cin >> x >> y;
if(x != 0 or y != 0) {
v.push_back(P(x, y));
}
}

sort(all(v), [&](P a, P b) { return argument(P(0, 0), a) < argument(P(0, 0), b); });

double ans = 0;
int n = v.size();
rep(i, 0, n) {
double x = 0, y = 0;
rep(j, 0, n) {
auto p = v[(i + j) % n];
x += real(p);
y += imag(p);

chmax(ans, sqrt(x * x + y * y));
}
}
printf("%.10f\n", ans);
}

```

#### 提出情報

提出日時 2019-09-04 21:54:32+0900 F - Engines hamayanhamayan C++14 (GCC 5.4.1) 600 2603 Byte AC 3 ms 512 KB

#### テストケース

セット名 得点 / 配点 テストケース
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
ケース名 結果 実行時間 メモリ
00-sample-01.txt 3 ms 512 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 2 ms 512 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