Submission #60363


ソースコード

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include <iostream>
#include <ios>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
template< typename T >
struct BinaryIndexedTree {
vector< T > data;
BinaryIndexedTree(int sz) {
data.assign(++sz, 0);
}
T sum(int k) {
T ret = 0;
for(++k; k > 0; k -= k & -k) ret += data[k];
return (ret);
}
void add(int k, T x) {
for(++k; k < data.size(); k += k & -k) data[k] += x;
}
};
signed main()
{
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
int T;
cin >> T;
vector<tuple<int, int, int> > query;
vector<double> res(T);
for(int i = 0; i < T; ++i){
int L, K;
cin >> L >> K;
query.emplace_back(L, K, i);
}
sort(query.begin(), query.end());
BinaryIndexedTree<int> bit(1000 * 1000 * 2 + 1);
int now_L = 0;
for(auto&& [L, K, query_num] : query){
while(now_L <= L){
for(int i = 0; i < now_L; ++i){
bit.add(now_L * now_L + i * i, 2);
}
bit.add(now_L * now_L * 2, 1);
++now_L;
}
int ng = -1, ok = 1000 * 1000 * 2;
while(ok - ng > 1){
int mid = (ok + ng) / 2;
if(bit.sum(mid) >= K){
ok = mid;
}else{
ng = mid;
}
}
res[query_num] = sqrt(ok);
}
for(auto&& e : res){
cout << fixed << setprecision(6) << e << '\n';
}
return (0);
}

ステータス

項目 データ
問題 1353 - Function of Euclidean Distance
ユーザー名 ei1903
投稿日時 2020-07-03 21:56:12
言語 C++17
状態 Accepted
得点 400
ソースコード長 1613 Byte
最大実行時間 186 ms
最大メモリ使用量 20992 KB

セット

セット 得点 Cases
1 task01 60 / 60 in01*, sample01.txt
2 task02 340 / 340 *

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
in01_01.txt AC 26 ms 8284 KB
1
2
in01_02.txt AC 34 ms 8360 KB
1
2
in01_03.txt AC 26 ms 8308 KB
1
2
in01_04.txt AC 37 ms 8260 KB
1
2
in01_05.txt AC 36 ms 8340 KB
1
2
in01_06.txt AC 23 ms 8420 KB
1
2
in01_07.txt AC 21 ms 8368 KB
1
2
in01_08.txt AC 20 ms 8436 KB
1
2
in01_09.txt AC 33 ms 8512 KB
1
2
in01_10.txt AC 31 ms 8464 KB
1
2
in02_01.txt AC 186 ms 11600 KB
2
in02_02.txt AC 141 ms 12896 KB
2
in02_03.txt AC 142 ms 13808 KB
2
in02_04.txt AC 95 ms 14848 KB
2
in02_05.txt AC 83 ms 15632 KB
2
in02_06.txt AC 146 ms 16680 KB
2
in02_07.txt AC 150 ms 17856 KB
2
in02_08.txt AC 144 ms 18772 KB
2
in02_09.txt AC 143 ms 19820 KB
2
in02_10.txt AC 157 ms 20992 KB
2
sample01.txt AC 27 ms 18844 KB
1
2
sample02.txt AC 33 ms 18920 KB
2