답안 #230568

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
230568 2020-05-10T13:03:56 Z AlexLuchianov Sure Bet (CEOI17_sure) C++14
0 / 100
5 ms 384 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <iomanip>

using namespace std;

using ll = long long;
using ld = long double;

#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))

int const nmax = 100000;
ld v[1 + nmax], v2[1 + nmax];

int main()
{
  int n;
  cin >> n;
  for(int i = 1;i <= n; i++)
    cin >> v[i] >> v2[i];
  sort(v + 1, v + n + 1);
  reverse(v + 1, v + n + 1);
  sort(v2 + 1, v2 + n + 1);
  reverse(v2 + 1, v2 + n + 1);

  vector<pair<ld,int>> sol;
  ld result = 0;
  for(int i = 1;i <= n; i++){
    v[i] += v[i - 1];
    v2[i] += v2[i - 1];
    sol.push_back({v[i], i});
    sol.push_back({v2[i], -i});
  }
  sort(sol.begin(), sol.end());
  reverse(sol.begin(), sol.end());
  int smin1 = n + 1, smin2 = n + 1;

  for(int i = 0; i < sol.size(); i++){
    if(0 < sol[i].second)
      smin1 = min(smin1, sol[i].second);
    else
      smin2 = min(smin2, -sol[i].second);
    if(smin1 <= n && smin2 <= n)
      result = max(result, ld(1) * sol[i].first - smin1 - smin2);
  }
  cout << setprecision(6) << fixed << result;
  return 0;
}

Compilation message

sure.cpp: In function 'int main()':
sure.cpp:42:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 0; i < sol.size(); i++){
                  ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -