제출 #1291896

#제출 시각아이디문제언어결과실행 시간메모리
1291896lmquanGlobal Warming (CEOI18_glo)C++20
100 / 100
43 ms4296 KiB
#define taskname ""
#include <bits/stdc++.h>
using namespace std;
const int kInf = 2000000000;

int main() {
  if (fopen(taskname".inp", "r")) {
    freopen(taskname".inp", "r", stdin);
    freopen(taskname".out", "w", stdout);
  }
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n, x;
  cin >> n >> x;
  vector<int> t(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> t[i];
  }

  vector<int> a(n + 1), e(n, kInf);
  for (int i = 1; i <= n; i++) {
    int u = lower_bound(e.begin(), e.end(), t[i]) - e.begin();
    a[i] = u + 1, e[u] = t[i];
  }
  
  vector<int> b(n + 1), f(n, kInf);
  for (int i = n; i >= 1; i--) {
    int u = lower_bound(f.begin(), f.end(), x - t[i]) - f.begin();
    int v = lower_bound(f.begin(), f.end(), -t[i]) - f.begin();
    
    b[i] = u + 1, f[v] = -t[i];
  }

  int result = 0;
  for (int i = 1; i <= n; i++) {
    result = max(result, a[i] + b[i] - 1);
  }
  cout << result;

  return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

glo.cpp: In function 'int main()':
glo.cpp:8:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |     freopen(taskname".inp", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
glo.cpp:9:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     freopen(taskname".out", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...