Submission #229446

#TimeUsernameProblemLanguageResultExecution timeMemory
229446bharat2002Sure Bet (CEOI17_sure)C++14
60 / 100
2064 ms4840 KiB
#include<bits/stdc++.h> using namespace std; const int N=1e5 + 100; const int mod=1e9 + 7; #define int long long const int inf=1e18; #define pii pair<int, int> #define f first #define s second #define mp make_pair #define FOR(i, n) for(int i=1;i<=n;i++) #define TRACE(x) cerr << #x << " = " << x << endl //Trace prints the name of the variable and the value. long double a[N], b[N];int n; bool sf(long double f, long double s) { return f>s; } signed main() { ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); cin>>n; for(int i=1;i<=n;i++) cin>>a[i]>>b[i]; sort(a+1, a+n+1, sf);sort(b+1, b+n+1, sf); for(int i=2;i<=n;i++) {a[i]+=a[i-1];b[i]+=b[i-1];} int i=1, j=1;a[n+1]=b[n+1]=1000000000; long double ans=0.0; for(int i=1;i<=n;i++) { for(int j=1;j<=n;j++) { ans=max(ans, min(a[i], b[j]) - i - j); } } cout<<fixed<<setprecision(4)<<ans; }

Compilation message (stderr)

sure.cpp: In function 'int main()':
sure.cpp:26:6: warning: unused variable 'i' [-Wunused-variable]
  int i=1, j=1;a[n+1]=b[n+1]=1000000000;
      ^
sure.cpp:26:11: warning: unused variable 'j' [-Wunused-variable]
  int i=1, j=1;a[n+1]=b[n+1]=1000000000;
           ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...