답안 #609721

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
609721 2022-07-27T19:52:23 Z MasterTaster Sure Bet (CEOI17_sure) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>

#define pb push_back
#define ll long long
#define pii pair<int, int>
#define xx first
#define yy second
#define MAXN 100010
#define long double double

using namespace std;

int n;
long double ress=0, a[MAXN], b[MAXN];

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    cin>>n;
    for (int i=0; i<n; i++) cin>>a[i]>>b[i];

    sort(a, a+n, greater<long double>());
    sort(b, b+n, greater<long double>());

    long double aa=0, bb=0;
    int i=0, j=0;
    while (i<n || j<n)
    {
        if (i==n || bb<=aa)
        {
            bb+=b[j++];
        }
        else if (j==n || aa<bb)
        {
            aa+=a[i++];
        }

        aa--; bb--;
        ress=max(ress, min(aa, bb));
    }
    cout<<fixed<<showpoint<<setprecision(4)<<ress<<endl;
}

Compilation message

sure.cpp:9:14: error: two or more data types in declaration of 'ress'
    9 | #define long double double
      |              ^~~~~~
sure.cpp:14:1: note: in expansion of macro 'long'
   14 | long double ress=0, a[MAXN], b[MAXN];
      | ^~~~
sure.cpp:9:14: error: two or more data types in declaration of 'a'
    9 | #define long double double
      |              ^~~~~~
sure.cpp:14:1: note: in expansion of macro 'long'
   14 | long double ress=0, a[MAXN], b[MAXN];
      | ^~~~
sure.cpp:9:14: error: two or more data types in declaration of 'b'
    9 | #define long double double
      |              ^~~~~~
sure.cpp:14:1: note: in expansion of macro 'long'
   14 | long double ress=0, a[MAXN], b[MAXN];
      | ^~~~
sure.cpp: In function 'int main()':
sure.cpp:20:34: error: 'a' was not declared in this scope
   20 |     for (int i=0; i<n; i++) cin>>a[i]>>b[i];
      |                                  ^
sure.cpp:20:40: error: 'b' was not declared in this scope
   20 |     for (int i=0; i<n; i++) cin>>a[i]>>b[i];
      |                                        ^
sure.cpp:22:10: error: 'a' was not declared in this scope
   22 |     sort(a, a+n, greater<long double>());
      |          ^
sure.cpp:9:14: error: two or more data types in declaration of 'type name'
    9 | #define long double double
      |              ^~~~~~
sure.cpp:22:26: note: in expansion of macro 'long'
   22 |     sort(a, a+n, greater<long double>());
      |                          ^~~~
sure.cpp:22:37: error: template argument 1 is invalid
   22 |     sort(a, a+n, greater<long double>());
      |                                     ^
sure.cpp:23:10: error: 'b' was not declared in this scope
   23 |     sort(b, b+n, greater<long double>());
      |          ^
sure.cpp:9:14: error: two or more data types in declaration of 'type name'
    9 | #define long double double
      |              ^~~~~~
sure.cpp:23:26: note: in expansion of macro 'long'
   23 |     sort(b, b+n, greater<long double>());
      |                          ^~~~
sure.cpp:23:37: error: template argument 1 is invalid
   23 |     sort(b, b+n, greater<long double>());
      |                                     ^
sure.cpp:9:14: error: two or more data types in declaration of 'aa'
    9 | #define long double double
      |              ^~~~~~
sure.cpp:25:5: note: in expansion of macro 'long'
   25 |     long double aa=0, bb=0;
      |     ^~~~
sure.cpp:9:14: error: two or more data types in declaration of 'bb'
    9 | #define long double double
      |              ^~~~~~
sure.cpp:25:5: note: in expansion of macro 'long'
   25 |     long double aa=0, bb=0;
      |     ^~~~
sure.cpp:29:21: error: 'bb' was not declared in this scope; did you mean 'pb'?
   29 |         if (i==n || bb<=aa)
      |                     ^~
      |                     pb
sure.cpp:29:25: error: 'aa' was not declared in this scope
   29 |         if (i==n || bb<=aa)
      |                         ^~
sure.cpp:38:9: error: 'aa' was not declared in this scope
   38 |         aa--; bb--;
      |         ^~
sure.cpp:38:15: error: 'bb' was not declared in this scope; did you mean 'pb'?
   38 |         aa--; bb--;
      |               ^~
      |               pb
sure.cpp:39:9: error: 'ress' was not declared in this scope
   39 |         ress=max(ress, min(aa, bb));
      |         ^~~~
sure.cpp:41:46: error: 'ress' was not declared in this scope
   41 |     cout<<fixed<<showpoint<<setprecision(4)<<ress<<endl;
      |                                              ^~~~