QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#486998#7689. Flipping Cardsucup-team3699#Compile Error//C++20951b2024-07-22 15:03:122024-07-22 15:03:12

Judging History

你现在查看的是最新测评结果

  • [2024-07-22 15:03:12]
  • 评测
  • [2024-07-22 15:03:12]
  • 提交

answer


using namespace std;
#define int long long 
#define N 300005
#define pii pair<int, int>
#define F first 
#define S second 
#define INF 2e9
pii a[N];
int n;
bool check(int k){
    vector<int> p1(n + 1, 0), p2(n + 1, 0);
    for (int i = 1; i <= n; i++){
        p1[i] = p1[i - 1] + (a[i].F >= k);
        p2[i] = p2[i - 1] + (a[i].S >= k);
    }
    int mi = 0, ret = 0;
    for (int r = 1; r <= n; r++){
        mi = min(mi, p2[r] - p1[r]);
        ret = max(ret, p1[n] - p1[r] + p2[r] - mi);
    }
    return ret >= ((n + 1) / 2);
}
void solve(){
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> a[i].F >> a[i].S;
    int ans = 0;
    for (int j = INF / 2; j; j >>= 1){
        while(check(ans + j))
            ans += j;
    }
    cout << ans << "\n";
}
signed main(){
    ios_base::sync_with_stdio(0), cin.tie(0);
    int t = 1;
    // cin >> t;
    while(t--)
        solve();
    return 0;
}

Details

answer.code:5:13: error: ‘pair’ does not name a type
    5 | #define pii pair<int, int>
      |             ^~~~
answer.code:9:1: note: in expansion of macro ‘pii’
    9 | pii a[N];
      | ^~~
answer.code: In function ‘bool check(long long int)’:
answer.code:12:5: error: ‘vector’ was not declared in this scope
   12 |     vector<int> p1(n + 1, 0), p2(n + 1, 0);
      |     ^~~~~~
answer.code:1:1: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’?
  +++ |+#include <vector>
    1 | 
answer.code:3:13: error: expected primary-expression before ‘long’
    3 | #define int long long
      |             ^~~~
answer.code:12:12: note: in expansion of macro ‘int’
   12 |     vector<int> p1(n + 1, 0), p2(n + 1, 0);
      |            ^~~
answer.code:14:9: error: ‘p1’ was not declared in this scope
   14 |         p1[i] = p1[i - 1] + (a[i].F >= k);
      |         ^~
answer.code:14:30: error: ‘a’ was not declared in this scope
   14 |         p1[i] = p1[i - 1] + (a[i].F >= k);
      |                              ^
answer.code:15:9: error: ‘p2’ was not declared in this scope
   15 |         p2[i] = p2[i - 1] + (a[i].S >= k);
      |         ^~
answer.code:19:22: error: ‘p2’ was not declared in this scope
   19 |         mi = min(mi, p2[r] - p1[r]);
      |                      ^~
answer.code:19:30: error: ‘p1’ was not declared in this scope
   19 |         mi = min(mi, p2[r] - p1[r]);
      |                              ^~
answer.code:19:14: error: ‘min’ was not declared in this scope; did you mean ‘mi’?
   19 |         mi = min(mi, p2[r] - p1[r]);
      |              ^~~
      |              mi
answer.code:20:15: error: ‘max’ was not declared in this scope
   20 |         ret = max(ret, p1[n] - p1[r] + p2[r] - mi);
      |               ^~~
answer.code: In function ‘void solve()’:
answer.code:25:5: error: ‘cin’ was not declared in this scope
   25 |     cin >> n;
      |     ^~~
answer.code:1:1: note: ‘std::cin’ is defined in header ‘<iostream>’; did you forget to ‘#include <iostream>’?
  +++ |+#include <iostream>
    1 | 
answer.code:27:16: error: ‘a’ was not declared in this scope
   27 |         cin >> a[i].F >> a[i].S;
      |                ^
answer.code:33:5: error: ‘cout’ was not declared in this scope
   33 |     cout << ans << "\n";
      |     ^~~~
answer.code:33:5: note: ‘std::cout’ is defined in header ‘<iostream>’; did you forget to ‘#include <iostream>’?
answer.code: In function ‘int main()’:
answer.code:36:5: error: ‘ios_base’ has not been declared
   36 |     ios_base::sync_with_stdio(0), cin.tie(0);
      |     ^~~~~~~~
answer.code:36:35: error: ‘cin’ was not declared in this scope
   36 |     ios_base::sync_with_stdio(0), cin.tie(0);
      |                                   ^~~
answer.code:36:35: note: ‘std::cin’ is defined in header ‘<iostream>’; did you forget to ‘#include <iostream>’?