답안 #865572

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
865572 2023-10-24T11:01:12 Z vjudge1 Sure Bet (CEOI17_sure) C++17
60 / 100
2000 ms 5672 KB
/// tree bends in youth
/// 24  .10.2023
/// success is doing same thing in every single day!!!
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define all(x) x.begin(), x.end()
#define F first
#define S second
using namespace std;
const ll N =2e5+ 5;
const ll NN =2e6 + 5;
const ll INF = -1e1;
const ll MOD = 1e9 + 7;
const ll LG = 18;
const ll k = 316;
int n;
double a[N],b[N],pl[N],pr[N];
void solve(){
    cin >> n;
    for(int i = 1;i <= n;i++){
        cin >> a[i] >> b[i];
    }
    sort(a + 1,a + n + 1);
    sort(b + 1,b + n + 1);
    reverse(a + 1,a+  n + 1);
    reverse(b + 1,b + n + 1);
    int z = 0,x = 0;
    for(int i = 1;i <= n;i++){
        pr[i] = pr[i - 1] + b[i];
        pl[i] = pl[i - 1] + a[i];
    }
    double ans = 0;
    for(int i = 1;i <= 2 * n;i++){
        for(int j = 0;j <=i;j++){
            double sum = double(i) + double(j);
            double z = pr[i - j];
            double x = pl[j];
            ans = max(ans,min(z,x)-i);
            //if( i == 3 ) cout << z << " " << x << " " << j << " " << ans << '\n' ;
        }
    }
    cout << fixed << setprecision(4) << ans;
}
main (){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
    ll abd= 1;
//    cin >> abd;
    for(ll i = 1;i <= abd;i++){
//        cout << "Case " << i << ":\n";
        solve();
    }
}

Compilation message

sure.cpp: In function 'void solve()':
sure.cpp:36:20: warning: unused variable 'sum' [-Wunused-variable]
   36 |             double sum = double(i) + double(j);
      |                    ^~~
sure.cpp:28:9: warning: unused variable 'z' [-Wunused-variable]
   28 |     int z = 0,x = 0;
      |         ^
sure.cpp:28:15: warning: unused variable 'x' [-Wunused-variable]
   28 |     int z = 0,x = 0;
      |               ^
sure.cpp: At global scope:
sure.cpp:45:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   45 | main (){
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 1 ms 2888 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 1 ms 2888 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2520 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 3 ms 2396 KB Output is correct
13 Correct 4 ms 2396 KB Output is correct
14 Correct 4 ms 2544 KB Output is correct
15 Correct 3 ms 2408 KB Output is correct
16 Correct 4 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 1 ms 2888 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2520 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 3 ms 2396 KB Output is correct
13 Correct 4 ms 2396 KB Output is correct
14 Correct 4 ms 2544 KB Output is correct
15 Correct 3 ms 2408 KB Output is correct
16 Correct 4 ms 2396 KB Output is correct
17 Execution timed out 2074 ms 5672 KB Time limit exceeded
18 Halted 0 ms 0 KB -