제출 #671396

#제출 시각아이디문제언어결과실행 시간메모리
671396Quan2003Global Warming (CEOI18_glo)C++17
0 / 100
167 ms45764 KiB
#include <bits/stdc++.h> #include <iostream> #include<vector> using namespace std; typedef long long ll; const int sz=5e5+10; const int sz1=1e6+1; const int inf=1e9 + 7; const int mod = 1e9 + 7; int n,m,k,w; long long d; long long a[sz]; long long pf[sz]; long long bit[sz]; void upd(int x,int diff){ for (int i = x; i < sz; i |= i + 1) bit[i]+=diff; } long long query(int x){ long long res = 0; for (int i = x; i >= 0; i = (i & (i + 1)) - 1) res = max(res,bit[i]); return res; } int main(){ cin>>n>>d; vector<long long>cor; for(int i = 1; i <= n; i++){ cin>>a[i]; cor.push_back(a[i]); cor.push_back(a[i] + d); cor.push_back(a[i] - d); } map<long long,int>mp; sort(cor.begin(),cor.end()); cor.erase(unique(cor.begin(),cor.end()),cor.end()); for(int i = 0; i < cor.size(); i++) mp[cor[i]] = i + 1; long long ans = 0; for(int i = 1; i <= n; i++){ long long mx = max(query(mp[a[i] - d]),max(query(a[i]),query(mp[a[i] + d]))); ans = max(mx + 1, ans); //upd(mp[a[i] - d],1); upd(mp[a[i]],1); //upd(mp[a[i] + d],1); } cout<<ans<<endl; }

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

glo.cpp: In function 'int main()':
glo.cpp:38:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |      for(int i = 0; i < cor.size(); i++) mp[cor[i]] = i + 1;
      |                     ~~^~~~~~~~~~~~
#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...