# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
472282 |
2021-09-13T11:06:40 Z |
Mr_Ph |
Cipele (COCI18_cipele) |
C++14 |
|
1000 ms |
5752 KB |
///made by : Mr_Ph :D
#include<bits/stdc++.h>
#include<unordered_map>
typedef long long ll;
typedef long long int lli;
typedef unsigned long long ull;
using namespace std;
const double PI=acos(-1.0);
const ll mod=(ll)1e9+7;
//int a1[4] = {0, 0, 1, -1};
//int b1[4] = {1, -1, 0, 0};
///the defines :)
#define endl '\n'
#define vi vector<int>
#define vll vector<ll>
#define lower(s) transform(s.begin(),s.end(),s.begin(),::tolower)
#define upper(s) transform(s.begin(),s.end(),s.begin(),::toupper)
#define ent(arr) for(int i=0;i<arr.size();i++)cin>>arr[i];
#define all(arr) arr.begin(),arr.end()
#define allr(arr) arr.rbegin(),arr.rend()
#define sz size()
///the end of the defines ;)
void solve()
{
int n,m;
cin>>n>>m;
deque<int>arr(n);
deque<int>brr(m);
ent(arr);
ent(brr);
map<int,int>mp;
sort(all(arr));
sort(all(brr));
int mxdiff=0,ans=0;
if(n>=m)
{
for(int i=0; i<m; i++)
{
int mndiff=INT_MAX;
for(int k=0; k<n; k++)
if(!mp[k])
mndiff=min(mndiff,abs(brr[i]-arr[k]));
for(int k=0; k<n; k++)
{
if(abs(arr[k]-brr[i])==mndiff&&!mp[k])
{
mp[k]++;
break;
}
}
ans=max(ans,mndiff);
}
}
else
{
for(int i=0; i<n; i++)
{
int mndiff=INT_MAX;
for(int k=0; k<m; k++)
if(!mp[k])
mndiff=min(mndiff,abs(arr[i]-brr[k]));
for(int k=0; k<n; k++)
{
if(abs(brr[k]-arr[i])==mndiff&&!mp[k])
{
mp[k]++;
break;
}
}
ans=max(ans,mndiff);
}
}
cout<<ans<<endl;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(0);
//freopen("window.in","r",stdin);
//freopen("output.txt","w",stdout);
int t=1;//int st;
//cin>>t;//cin>>st;
while(t--)
solve();
}
Compilation message
cipele.cpp: In function 'void solve()':
cipele.cpp:18:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
18 | #define ent(arr) for(int i=0;i<arr.size();i++)cin>>arr[i];
| ~^~~~~~~~~~~
cipele.cpp:29:5: note: in expansion of macro 'ent'
29 | ent(arr);
| ^~~
cipele.cpp:18:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
18 | #define ent(arr) for(int i=0;i<arr.size();i++)cin>>arr[i];
| ~^~~~~~~~~~~
cipele.cpp:30:5: note: in expansion of macro 'ent'
30 | ent(brr);
| ^~~
cipele.cpp:34:9: warning: unused variable 'mxdiff' [-Wunused-variable]
34 | int mxdiff=0,ans=0;
| ^~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1063 ms |
5752 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1091 ms |
5700 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
286 ms |
436 KB |
Output is correct |
2 |
Execution timed out |
1091 ms |
460 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
564 KB |
Output is correct |
2 |
Execution timed out |
1089 ms |
460 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1010 ms |
564 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
996 ms |
580 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1090 ms |
460 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1086 ms |
5448 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1085 ms |
5316 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1089 ms |
5188 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |