제출 #731794

#제출 시각아이디문제언어결과실행 시간메모리
731794beabossGlobal Warming (CEOI18_glo)C++14
100 / 100
108 ms4304 KiB
#include "bits/stdc++.h" using namespace std; #define s second #define f first #define pb push_back typedef long long ll; typedef vector<int> vi; typedef pair<int, int> pii; // const int INF = 1e17; const int N = 2*1e5 + 10; int main() { int n, x; cin >> n >> x; vi vals(n); vi dp(n); vi cur; for (int i = 0; i < n; i++) { cin >> vals[i]; auto ind = lower_bound(cur.begin(), cur.end(), vals[i]) - cur.begin(); if (ind == cur.size()) cur.pb(vals[i]); else cur[ind] = vals[i]; // cout << i << ind << endl; dp[i]=ind+1; } cur.erase(cur.begin(), cur.end()); int ans = 0; for (int i = n-1; i >= 0; i--) { int possible = lower_bound(cur.begin(), cur.end(), -vals[i] + x) - cur.begin(); // cout << i << possible << dp[i] << endl; ans = max(ans, dp[i] + possible); int ind = lower_bound(cur.begin(), cur.end(), -vals[i]) - cur.begin(); if (ind == cur.size()) cur.pb(-vals[i]); else cur[ind]=-vals[i]; } // cout << cur.size() << endl; // assert(dp[n-1] == cur.size()); cout << ans << endl; }

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

glo.cpp: In function 'int main()':
glo.cpp:31:11: warning: comparison of integer expressions of different signedness: 'long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |   if (ind == cur.size()) cur.pb(vals[i]);
      |       ~~~~^~~~~~~~~~~~~
glo.cpp:45:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |   if (ind == cur.size()) cur.pb(-vals[i]);
      |       ~~~~^~~~~~~~~~~~~
#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...