제출 #954686

#제출 시각아이디문제언어결과실행 시간메모리
954686WarinchaiLightning Rod (NOI18_lightningrod)C++14
100 / 100
1415 ms262144 KiB
#include<bits/stdc++.h> using namespace std; vector<pair<int,int>>v; bool check(pair<int,int>f,pair<int,int>s){ return abs(f.first-s.first)<=f.second-s.second; } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); int n;cin>>n; for(int i=1;i<=n;i++){ int a,b;cin>>a>>b; v.push_back({a,b}); } stack<pair<int,int>>st; st.push(v[0]); for(int i=1;i<n;i++){ int a=v[i].first; int b=v[i].second; if(!check(st.top(),v[i])){ while(!st.empty()&&check(v[i],st.top())){ st.pop(); } st.push(v[i]); } } cout<<st.size(); }

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

lightningrod.cpp: In function 'int main()':
lightningrod.cpp:18:13: warning: unused variable 'a' [-Wunused-variable]
   18 |         int a=v[i].first;
      |             ^
lightningrod.cpp:19:13: warning: unused variable 'b' [-Wunused-variable]
   19 |         int b=v[i].second;
      |             ^
#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...