Submission #1318109

#TimeUsernameProblemLanguageResultExecution timeMemory
1318109kawhietGlobal Warming (CEOI18_glo)C++20
Compilation error
0 ms0 KiB
a#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, x; cin >> n >> x; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } vector<int> l(n), r(n); set<int> s; for (int i = 0; i < n; i++) { auto it = s.lower_bound(a[i]); if (it != s.end()) { s.erase(it); } s.insert(a[i]); l[i] = s.size(); } set<int> t; for (int i = n - 1; i >= 0; i--) { auto it = t.lower_bound(-a[i]); if (it != t.end()) { t.erase(it); } t.insert(-a[i]); r[i] = t.size(); } int ans = s.size(); for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (a[i] - a[j] < x) { ans = max(ans, l[i] + r[j]); } } } cout << ans << '\n'; return 0; }

Compilation message (stderr)

glo.cpp:1:2: error: stray '#' in program
    1 | a#include <bits/stdc++.h>
      |  ^
glo.cpp:1:1: error: 'a' does not name a type
    1 | a#include <bits/stdc++.h>
      | ^
glo.cpp: In function 'int main()':
glo.cpp:5:5: error: 'ios' has not been declared
    5 |     ios::sync_with_stdio(false);
      |     ^~~
glo.cpp:6:5: error: 'cin' was not declared in this scope
    6 |     cin.tie(nullptr);
      |     ^~~
glo.cpp:9:5: error: 'vector' was not declared in this scope
    9 |     vector<int> a(n);
      |     ^~~~~~
glo.cpp:9:12: error: expected primary-expression before 'int'
    9 |     vector<int> a(n);
      |            ^~~
glo.cpp:11:16: error: 'a' was not declared in this scope
   11 |         cin >> a[i];
      |                ^
glo.cpp:13:12: error: expected primary-expression before 'int'
   13 |     vector<int> l(n), r(n);
      |            ^~~
glo.cpp:14:5: error: 'set' was not declared in this scope
   14 |     set<int> s;
      |     ^~~
glo.cpp:14:9: error: expected primary-expression before 'int'
   14 |     set<int> s;
      |         ^~~
glo.cpp:16:19: error: 's' was not declared in this scope
   16 |         auto it = s.lower_bound(a[i]);
      |                   ^
glo.cpp:16:33: error: 'a' was not declared in this scope
   16 |         auto it = s.lower_bound(a[i]);
      |                                 ^
glo.cpp:21:9: error: 'l' was not declared in this scope
   21 |         l[i] = s.size();
      |         ^
glo.cpp:23:9: error: expected primary-expression before 'int'
   23 |     set<int> t;
      |         ^~~
glo.cpp:25:19: error: 't' was not declared in this scope; did you mean 'it'?
   25 |         auto it = t.lower_bound(-a[i]);
      |                   ^
      |                   it
glo.cpp:25:34: error: 'a' was not declared in this scope
   25 |         auto it = t.lower_bound(-a[i]);
      |                                  ^
glo.cpp:30:9: error: 'r' was not declared in this scope
   30 |         r[i] = t.size();
      |         ^
glo.cpp:32:15: error: 's' was not declared in this scope
   32 |     int ans = s.size();
      |               ^
glo.cpp:35:17: error: 'a' was not declared in this scope
   35 |             if (a[i] - a[j] < x) {
      |                 ^
glo.cpp:36:32: error: 'l' was not declared in this scope
   36 |                 ans = max(ans, l[i] + r[j]);
      |                                ^
glo.cpp:36:39: error: 'r' was not declared in this scope
   36 |                 ans = max(ans, l[i] + r[j]);
      |                                       ^
glo.cpp:36:23: error: 'max' was not declared in this scope
   36 |                 ans = max(ans, l[i] + r[j]);
      |                       ^~~
glo.cpp:40:5: error: 'cout' was not declared in this scope
   40 |     cout << ans << '\n';
      |     ^~~~