# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
849454 | 2023-09-14T16:01:25 Z | Benmath | Measures (CEOI22_measures) | C++14 | 1500 ms | 7136 KB |
/****************************************************************************** Online C++ Compiler. Code, Compile, Run and Debug C++ program online. Write your code in this editor and press "Run" button to compile and execute it. *******************************************************************************/ #include <bits/stdc++.h> using namespace std; int broj_ljudi, broj_dodatnih; double maksimalna_udaljenost; double ljudi[200010]; double dodatniljudi[11]; int check (double mid, vector<double>v){ int provjera = 0; double prethodni = v[0] - mid; for(int i = 1; i < v.size(); i++){ double mogucnost1 = v[i] - mid; double mogucnost2 = v[i] + mid; double moguce = prethodni + maksimalna_udaljenost; if(mogucnost1 >= moguce){ prethodni = mogucnost1; }else if (moguce <= mogucnost2){ prethodni = moguce; }else{ provjera++; break; } } return provjera; } void ispisi(double x){ long long int x1 = x; double x2 = x1; if(x==x2){ cout<<x1; }else{ cout<<fixed<<setprecision(1)<<x; } cout<<" "; } int main() { cin>>broj_ljudi; cin>>broj_dodatnih; cin>>maksimalna_udaljenost; vector<double>v; for (int i = 0; i < broj_ljudi; i++){ cin >> ljudi[i]; v.push_back(ljudi[i]); } vector<double>ansispis; for(int i = 0; i < broj_dodatnih; i++){ cin >> dodatniljudi[i]; v.push_back(dodatniljudi[i]); sort(v.begin(), v.end()); long long int l = 0; long long int r = 10000000000000000; double ans = 10000000000000000; double two = 2; while (l <= r){ long long int mid = (l + r) / 2; double mid1 = mid; double provjerit = mid1 / two; if(check(provjerit,v) == 0){ ans = min(ans,provjerit); r = mid - 1; }else{ l = mid + 1; } } ansispis.push_back(ans); } for(int i = 0; i < ansispis.size(); i++){ ispisi(ansispis[i]); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 344 KB | Output is correct |
2 | Correct | 3 ms | 348 KB | Output is correct |
3 | Correct | 2 ms | 348 KB | Output is correct |
4 | Correct | 3 ms | 348 KB | Output is correct |
5 | Correct | 2 ms | 348 KB | Output is correct |
6 | Correct | 3 ms | 348 KB | Output is correct |
7 | Correct | 3 ms | 504 KB | Output is correct |
8 | Correct | 2 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 344 KB | Output is correct |
2 | Correct | 3 ms | 348 KB | Output is correct |
3 | Correct | 2 ms | 348 KB | Output is correct |
4 | Correct | 3 ms | 348 KB | Output is correct |
5 | Correct | 2 ms | 348 KB | Output is correct |
6 | Correct | 3 ms | 348 KB | Output is correct |
7 | Correct | 3 ms | 504 KB | Output is correct |
8 | Correct | 2 ms | 348 KB | Output is correct |
9 | Correct | 326 ms | 6968 KB | Output is correct |
10 | Correct | 356 ms | 7104 KB | Output is correct |
11 | Correct | 235 ms | 7136 KB | Output is correct |
12 | Correct | 365 ms | 7004 KB | Output is correct |
13 | Correct | 206 ms | 6524 KB | Output is correct |
14 | Correct | 561 ms | 7128 KB | Output is correct |
15 | Correct | 249 ms | 6340 KB | Output is correct |
16 | Correct | 241 ms | 7104 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1561 ms | 880 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1561 ms | 880 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |