제출 #95187

#제출 시각아이디문제언어결과실행 시간메모리
95187Retro3014Global Warming (CEOI18_glo)C++17
10 / 100
68 ms3984 KiB
#include <iostream> #include <stdio.h> #include <algorithm> #include <vector> using namespace std; #define MAX_N 200000 int N, D; vector<int> v; vector<int> stack; int num[MAX_N+1]; int ans = 0; int main(){ scanf("%d %d", &N, &D); int x; for(int i=0; i<N; i++){ scanf("%d", &x); v.push_back(x); } for(int i=v.size()-1; i>=0; i--){ if(stack.empty()){ num[i] = 1; stack.push_back(v[i]); }else{ if(stack.back()>v[i]){ stack.push_back(v[i]); num[i] = stack.size(); }else{ int s = 0, e = stack.size()-1, m; while(s<e){ m = (s+e)/2; if(stack[m]>v[i]) s = m+1; else e = m; } num[i] = s+1; stack[s] = v[i]; } } } stack.clear(); for(int i=0; i<v.size(); i++){ int s = 0, e = stack.size()-1, m; while(s<e){ m=(s+e)/2; if(stack[m]<v[i]+D) s = m+1; else e = m; } ans = max(ans, s+num[i]); if(stack.empty()){ stack.push_back(v[i]); }else{ if(stack.back()<v[i]) stack.push_back(v[i]); else{ s = 0; e = stack.size()-1; while(s<e){ m = (s+e)/2; if(stack[m]<v[i]) s = m+1; else e = m; } stack[s] = v[i]; } } } printf("%d", ans); return 0; }

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

glo.cpp: In function 'int main()':
glo.cpp:43:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<v.size(); i++){
               ~^~~~~~~~~
glo.cpp:17:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &N, &D);
  ~~~~~^~~~~~~~~~~~~~~~~
glo.cpp:20:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &x); v.push_back(x);
   ~~~~~^~~~~~~~~~
#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...