제출 #282786

#제출 시각아이디문제언어결과실행 시간메모리
282786dooweyGlobal Warming (CEOI18_glo)C++14
0 / 100
5 ms5248 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, int> pii; #define fi first #define se second #define mp make_pair #define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); const ll inf = (ll)1e10; const int N = (int)2e5 + 10; vector<pii> qq[N]; int main(){ fastIO; freopen("in.txt", "r", stdin); int n; ll x; cin >> n >> x; vector<ll> v(n); for(int i = 0 ; i < n; i ++ ){ cin >> v[i]; } vector<ll> q; ll c; int id; int res = 0; for(int i = 0 ; i < n; i ++ ){ c = v[i] - x; id = lower_bound(q.begin(), q.end(), c) - q.begin(); if(id == q.size()){ q.push_back(c); } else{ q[id] = c; } qq[i+1].push_back(mp(c, id+1)); res = max(res, id + 1); } vector<ll> g = {}; int l, r, mid; for(int i = n - 1; i >= 0; i -- ){ l = 0, r = g.size(); while(l < r){ mid = (l + r) / 2; if(g[mid] > v[i]){ l = mid + 1; } else{ r = mid; } } if(l == g.size()){ g.push_back(v[i]); } else{ g[l] = v[i]; } for(auto x : qq[i]){ l = 0, r = g.size(); while(l + 1 < r){ mid = (l + r) / 2; if(g[mid] > x.fi) l = mid; else r = mid; } res = max(res, l + (g[l]>x.fi) + x.se); } } cout << res << "\n"; return 0; }

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

glo.cpp: In function 'int main()':
glo.cpp:34:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |         if(id == q.size()){
      |            ~~~^~~~~~~~~~~
glo.cpp:56:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |         if(l == g.size()){
      |            ~~^~~~~~~~~~~
glo.cpp:19:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   19 |     freopen("in.txt", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
#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...