답안 #849423

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
849423 2023-09-14T15:18:14 Z Benmath Measures (CEOI22_measures) C++14
0 / 100
1500 ms 868 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;
}
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 = 1e16;
      double ans = 1e16;
      double two = 2;
      while (l <= r){
         long long int mid = (l + r) / two;
         double mid1 = mid;
         double provjerit = mid1 / two;
         if(check(provjerit,v) == 0){
            ans = min(ans,provjerit);
            r = mid - 1;
         }else{
            l = mid + 1;
         }
     }
     cout<<ans<<endl;
     ansispis.push_back(ans);
  }
  for(int i = 0; i < ansispis.size(); i++){
      cout<<ansispis[i]<<" ";
  }
  
  

}

Compilation message

Main.cpp: In function 'int check(double, std::vector<double>)':
Main.cpp:19:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<double>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |     for(int i = 1; i < v.size(); i++){
      |                    ~~^~~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:68:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<double>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   68 |   for(int i = 0; i < ansispis.size(); i++){
      |                  ~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1517 ms 868 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1517 ms 868 KB Time limit exceeded
2 Halted 0 ms 0 KB -