CSES - Bonus contest - Results
Submission details
Task:Mountain Biking
Sender:lazycoder
Submission time:2015-11-25 17:43:20 +0200
Language:C++
Status:READY
Result:
Test results
testverdicttime
#10.05 sdetails
#20.06 sdetails
#30.05 sdetails
#40.06 sdetails
#50.05 sdetails
#60.06 sdetails
#70.05 sdetails
#80.05 sdetails
#90.05 sdetails

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:26:41: warning: format '%Ld' expects argument of type 'long long int', but argument 2 has type 'long int' [-Wformat=]
         printf("%Ld\n", std::lround(out));
                                         ^

Code

#include <iostream>
#include <cstdio>
#include <cmath>
#include <cerrno>
#include <cfenv>
using namespace std;
const double pi = std::acos(-1);
int main() {
int N, D, ang, g;
long double *H, totH = 0, covH = 0, out;
cin>>N;
cin>>g;
H = new long double[N];
for (int i = 0; i < N; i++) {
cin >> D;
cin >> ang;
H[i] = D * std::cos(ang * pi / 180);
totH += H[i];
}
for (int j = 0; j < N; j++) {
out = 2 * g * (totH - covH);
out = std::sqrt(out);
printf("%Ld\n", std::lround(out));
covH += H[j];
}
return 0;
}

Test details

Test 1

Verdict:

input
4 1
1000 89
1000 88
1000 87
1000 86

correct output
18.67856167518548
17.71958953754687
15.62641545506002
11.81155990918434

user output
19
18
16
12

Test 2

Verdict:

input
4 100
994 89
991 84
999 89
773 81

correct output
227.72535853692241
219.97568165830942
166.34830657806216
155.51452760182793

user output
228
220
166
156

Test 3

Verdict:

input
4 1
603 1
11 20
778 2
313 1

correct output
58.37333588228029
46.92153047021062
46.70071502674894
25.01808660085541

user output
58
47
47
25

Test 4

Verdict:

input
3 100
1000 1
1000 2
998 1

correct output
774.22044947696459
632.01880142685220
446.73213445331610

user output
774
632
447

Test 5

Verdict:

input
4 33
600 20
600 40
600 60
600 80

correct output
306.95871964523821
238.77149700733121
163.32932325706381
82.92447066825597

user output
307
239
163
83

Test 6

Verdict:

input
4 81
627 80
822 60
411 40
801 20

correct output
507.11074231227801
489.41103887240717
415.86195422299554
349.19392013381482

user output
507
489
416
349

Test 7

Verdict:

input
1 65.678904776
5999 83

correct output
309.895033063524

user output
0

Test 8

Verdict:

input
3 16.5485760467
9210 5
3641 10
7313 12

correct output
811.8442666570775
596.1763940359323
486.5699641893223

user output
0
0
0

Test 9

Verdict:

input
1 19.5935866382
6927 30

correct output
484.85276685524383

user output
0