[ create a new paste ] login | about

Link: http://codepad.org/uQhX4kbi    [ raw code | output | fork | 1 comment ]

C++, pasted on Dec 29:
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<sstream>
#include<cassert>
#include<queue>
#include<stack>
#include<bitset>
#include<cstring>

#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define ALL(C)     (C).begin(),(C).end()
#define FOR(it,o)  for(__typeof((o).begin()) it=(o).begin(); it!=(o).end(); ++it)

using namespace std;
const long double EPS = 0.000000001;
const long double INF = 1000000001;
typedef long long lli;
int main(){
  int n;
  cin >> n;
  vector<int> pos(n);
  rep(i, n)cin >> pos[i];
  sort(ALL(pos));
  long double left= 0, right = INF, ans[3], d = INF;
  while(right - left > EPS){
    long double now = (left + right)/2, tmp[3];
    vector<int>::iterator p = pos.begin();
    rep(i, 3){
      tmp[i] = now + (*p);
      p = upper_bound(p, pos.end() , now*2 + (*p) );
    }
    if(p == pos.end()){
      if(now < d){
        rep(i, 3){
        ans[i] = tmp[i];
        if(i > 0 && ans[i] < ans[i-1])ans[i] = ans[i-1];
        }
        d = min(d, now);
      }
      right = now;
    }
    if(p != pos.end()){
      left = now;
    }
  }
  if(d > INF - 100)assert(false);
  sort(ans, ans+3);
  printf("%.6lf\n",(double)d);
  printf("%.6lf %.6lf %.6lf\n", (double)ans[0], (double)ans[1], (double)ans[2]);
  return 0;
}


Output:
1
2
Line 25: error: ISO C++ does not support 'long long'
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments:
posted by shioshiota on Dec 29
This is the code I submitted at the contest.
The submitID is 232174.
It returns
"232174 Dec 28, 2010 8:18:20 PM shioshiota C - Three Base Stations GNU C++ Runtime error on test 42 660 ms 2104 KB".
But I submitted the "same" code.
It returns "234754 Dec 29, 2010 11:35:45 AM shioshiota C - Three Base Stations GNU C++ Accepted 660 ms 2104 KB".

reply