Submission #1070208

#TimeUsernameProblemLanguageResultExecution timeMemory
1070208naneosmicSprinklers (CEOI24_sprinklers)C++14
0 / 100
33 ms3860 KiB
#include <bits/stdc++.h> #define int long long #define endl "\n" using namespace std; signed main(){ int n,m; cin>>n>>m; set<int>nums; vector<int>sprinklers(n); vector<int>flowers(m); for(int i=0;i<n;i++)cin>>sprinklers[i]; for(int i=0;i<m;i++)cin>>flowers[i]; for(int i=0;i<n;i++)nums.insert(sprinklers[i]); for(int i=0;i<m;i++)nums.insert(flowers[i]); int maxdistance=-1; bool flag=false; if(n==1){ auto it1=nums.begin(); auto it2=nums.end();it2--; if((sprinklers[0]!=(*it1)&&sprinklers[0]!=(*it2))){ cout<<-1<<endl; flag=true; } } if(!flag){ for(int i=0;i<m;i++){ int mindistance=INT_MAX; for(int j=0;j<n;j++){ mindistance=min(mindistance,abs(sprinklers[j]-flowers[i])); } maxdistance=max(maxdistance,mindistance); } cout<<maxdistance<<endl; } }
#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...