Submission #938268

#TimeUsernameProblemLanguageResultExecution timeMemory
938268vjudge1Sure Bet (CEOI17_sure)C++17
0 / 100
0 ms344 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define pii pair<int,int> using namespace __gnu_pbds; using namespace std; #define pb push_back #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() #define f first #define int double #define s second #define pii pair<int,int> template<class T>bool umax(T &a,T b){if(a<b){a=b;return true;}return false;} template<class T>bool umin(T &a,T b){if(b<a){a=b;return true;}return false;} typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; const int N=3e5 + 5 ; const int inf = 1e17 + 7; const int mod = 998244353; long long binpow(long long n, long long m){ if(m == 0)return 1; else if(m % 2 == 0){ long long sum = binpow(n,m/2); return sum * sum; } else{ return binpow(n,m-1)*n; } } void solve(){ int n,m,k; cin>>n; vector<int>l,r; for(int i = 0;i<n;i++){ int a,b; cin>>a>>b; l.pb(a); r.pb(b); } sort(rall(l)); sort(rall(r)); int i = 0, j = 0; int ans = 0; int sum1 = 0, sum2 = 0; int cnt = 0; while(i<n&&j<n){ if(sum1-cnt<=sum2-cnt){ sum1 += l[i]; cnt += 1; i += 1; } else { sum2 += r[j]; cnt += 1; j += 1; } umax(ans,min(sum1-cnt,sum2-cnt)); } printf("%.4lf",(double)ans); } signed main() { // freopen("seq.in", "r", stdin); // freopen("seq.out", "w", stdout); ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL); int tt=1;//cin>>tt>>n; while(tt--)solve(); }

Compilation message (stderr)

sure.cpp: In function 'void solve()':
sure.cpp:37:8: warning: unused variable 'm' [-Wunused-variable]
   37 |  int n,m,k;
      |        ^
sure.cpp:37:10: warning: unused variable 'k' [-Wunused-variable]
   37 |  int n,m,k;
      |          ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...