Submission #206782

#TimeUsernameProblemLanguageResultExecution timeMemory
206782DodgeBallManSure Bet (CEOI17_sure)C++14
0 / 100
5 ms376 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; int n, p1, p2; double a[N], b[N], ans, sum1, sum2; int main() { scanf("%d",&n); for( int i = 1 ; i <= n ; i++ ) { scanf("%lf %lf",&a[i],&b[i]); a[i] = a[i] - 1, b[i] = b[i] - 1; //cout << a[i] << " " << b[i] << endl; } sort( a + 1, a + 1 + n, greater<double>() ), sort( b + 1, b + 1 + n, greater<double>() ); for( int i = 1 ; i <= n ; i++ ) cout << a[i] << " " << b[i] << endl; p1 = p2 = 1; if( a[1] >= b[1] ) { sum1 += a[1], sum2 -= 1.0; p1++; } else { sum2 += b[1], sum1 -= 1.0; p2++; } while( p1 <= n && p2 <= n ) { //cout << sum1 << " " << sum2 << endl; if( sum1 <= sum2 ) { sum1 += a[p1], sum2 -= 1.0; p1++; } else { sum2 += b[p1], sum1 -= 1.0; p2++; } ans = max( ans, min( sum1, sum2 ) ); } while( p1 <= n ) { sum1 += a[p1], sum2 -= 1.0; p1++; ans = max( ans, min( sum1, sum2 ) ); } while( p2 <= n ) { sum2 += b[p2], sum1 -= 1.0; p2++; ans = max( ans, min( sum1, sum2 ) ); } printf("%.4f",ans); return 0; }

Compilation message (stderr)

sure.cpp: In function 'int main()':
sure.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
sure.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lf %lf",&a[i],&b[i]);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...