# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
169437 | Ruxandra985 | Sure Bet (CEOI17_sure) | C++14 | 2 ms | 376 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/// pe langa faptul ca sunt inteligenta si nu stiu sa citesc enunturi
/// cateodata mai si uit sa trec pe standard input/output si iau 0 degeaba:)
#include <bits/stdc++.h>
#define DIMN 100010
using namespace std;
double v[DIMN],w[DIMN] , spv[DIMN] , spw[DIMN];
double check (int x , int y){
return min(spv[x] - x - y , spw[y] - x - y);
}
int main()
{
FILE *fin = stdin;
int n , i , j , taken = 0 , st , dr , mid , nr;
double sol = 0.0 ,x , y, z;
fscanf (fin,"%d",&n);
for (i=1;i<=n;i++){
fscanf (fin,"%lf%lf",&v[i],&w[i]);
}
sort (v+1 , v + n + 1);
sort (w+1 , w + n + 1);
for (i=1;i<=n-i+1;i++){
swap(v[i] , v[n-i+1]);
swap(w[i] , w[n-i+1]);
}
for (i=1;i<=n;i++){
spv[i] = spv[i-1] + v[i];
spw[i] = spw[i-1] + w[i];
}
spv[0] = spw[0] = -2000000000;
spv[n+1] = spw[n+1] = 2000000000;
for (i=1;i<=n;i++){
/// avem spv[i]
/// pot sa caut ternar sol pe w
st = 1;
dr = n;
nr = 100;
while (st <= dr && nr){
mid = (st + dr)/2;
x = check(i , mid-1);
y = check(i , mid);
z = check(i , mid+1);
if (x <= y && y <= z){ /// solutie
sol = max(sol , min(spv[i] - i - mid , spw[mid] - i - mid));
break;
}
else if (x <= y && y <= z)
st = mid;
else dr = mid;
nr--;
}
sol = max(sol , min(spv[i] - i - mid , spw[mid] - i - mid));
}
cout << setprecision(4) << fixed << sol;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |