제출 #993450

#제출 시각아이디문제언어결과실행 시간메모리
993450AndrijaM지구 온난화 (NOI13_gw)C++14
0 / 40
2204 ms65536 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int maxn=1e6+10; const int mod=1e9+7; set<int>pos[maxn]; signed main() { ios::sync_with_stdio(false); cin.tie(0); ///freopen("prieteni.in","r",stdin); ///freopen("prieteni.out","w",stdout); int n; cin>>n; int x[n]; vector<int>v; for(int i=0;i<n;i++) { cin>>x[i]; v.push_back(x[i]); pos[x[i]].insert(i); } sort(v.begin(),v.end()); auto it=unique(v.begin(),v.end()); v.resize(distance(v.begin(),it)); bool vis[n]; memset(vis,0,sizeof vis); int ans=1; int sum=1; for(int i=0;i<v.size();i++) { int koj=v[i]; for(auto idx:pos[koj]) { if(idx==0 || idx==n-1) { sum--; vis[idx]=1; continue; } if(vis[idx-1]==0 && vis[idx+1]==0) { sum++; vis[idx]=1; continue; } if(vis[idx-1]==1 && vis[idx+1]==1) { sum--; vis[idx]=1; continue; } vis[idx]=1; } ans=max(ans,sum); } cout<<ans<<endl; return 0; }

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

gw.cpp: In function 'int main()':
gw.cpp:36:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     for(int i=0;i<v.size();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...