제출 #169437

#제출 시각아이디문제언어결과실행 시간메모리
169437Ruxandra985Sure Bet (CEOI17_sure)C++14
0 / 100
2 ms376 KiB
/// 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) 메시지

sure.cpp: In function 'int main()':
sure.cpp:14:17: warning: unused variable 'j' [-Wunused-variable]
     int n , i , j , taken = 0 , st , dr , mid , nr;
                 ^
sure.cpp:14:21: warning: unused variable 'taken' [-Wunused-variable]
     int n , i , j , taken = 0 , st , dr , mid , nr;
                     ^~~~~
sure.cpp:16:12: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     fscanf (fin,"%d",&n);
     ~~~~~~~^~~~~~~~~~~~~
sure.cpp:18:16: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         fscanf (fin,"%lf%lf",&v[i],&w[i]);
         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...