Submission #472312

#TimeUsernameProblemLanguageResultExecution timeMemory
472312MamdouhNCipele (COCI18_cipele)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define endl "\n" vector<int>R,L,nR; int required; int dp[30000][30003]; int solve(int i,int taken) { //cout<<i<<" "<<taken<<endl; if(taken == 0) return 0; if(taken - (L.size()-i)>0)return 1e9; if(i==L.size())return 1e9; if(dp[i][taken]!=-1)return dp[i][taken]; int ret; ret = solve(i+1,taken); int idx1 = lower_bound(R.begin(),R.end(),L[i])-R.begin(); int idx2 = lower_bound(nR.begin(),nR.end(),L[i]*-1)-nR.begin(); int idx; if(idx1==R.size())idx1--; if(idx2==nR.size())idx2--; if( abs((L[i]*-1) - nR[idx2]) < abs((L[i]) - R[idx1]) ) idx = R.size()-idx2-1; else idx = idx1; int ans=abs(L[i]-R[idx]); vector<int>x,y; x=R; y=nR; R.erase(R.begin()+idx); nR.erase(nR.begin()+(nR.size()-idx-1)); ret = min(ret,max(ans,solve(i+1,taken-1))); R=x; nR=y; return dp[i][taken] = ret; } main() { memset(dp,-1,sizeof dp); int n,m; cin>>n>>m; for(int i=0;i<n;i++) { int x; cin>>x; L.push_back(x); } for(int i=0;i<m;i++) { int x; cin>>x; R.push_back(x); } if(n>m) { swap(m,n); swap(L,R); } required = n; for(int i=0;i<R.size();i++)nR.push_back(R[i]*-1); sort(L.begin(),L.end()); sort(R.begin(),R.end()); sort(nR.begin(),nR.end()); int ans = 0; cout<<solve(0,required)<<endl; }

Compilation message (stderr)

cipele.cpp: In function 'long long int solve(long long int, long long int)':
cipele.cpp:15:9: 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]
   15 |     if(i==L.size())return 1e9;
      |        ~^~~~~~~~~~
cipele.cpp:22:12: 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]
   22 |     if(idx1==R.size())idx1--;
      |        ~~~~^~~~~~~~~~
cipele.cpp:23:12: 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]
   23 |     if(idx2==nR.size())idx2--;
      |        ~~~~^~~~~~~~~~~
cipele.cpp: At global scope:
cipele.cpp:42:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   42 | main()
      | ^~~~
cipele.cpp: In function 'int main()':
cipele.cpp:66: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]
   66 |     for(int i=0;i<R.size();i++)nR.push_back(R[i]*-1);
      |                 ~^~~~~~~~~
cipele.cpp:71:9: warning: unused variable 'ans' [-Wunused-variable]
   71 |     int ans = 0;
      |         ^~~
/tmp/ccWVDpal.o: in function `solve(long long, long long)':
cipele.cpp:(.text+0x61a): relocation truncated to fit: R_X86_64_PC32 against symbol `L' defined in .bss section in /tmp/ccWVDpal.o
cipele.cpp:(.text+0x62a): relocation truncated to fit: R_X86_64_PC32 against symbol `L' defined in .bss section in /tmp/ccWVDpal.o
cipele.cpp:(.text+0x6ac): relocation truncated to fit: R_X86_64_PC32 against symbol `R' defined in .bss section in /tmp/ccWVDpal.o
cipele.cpp:(.text+0x6b3): relocation truncated to fit: R_X86_64_PC32 against symbol `R' defined in .bss section in /tmp/ccWVDpal.o
cipele.cpp:(.text+0x6bf): relocation truncated to fit: R_X86_64_PC32 against symbol `L' defined in .bss section in /tmp/ccWVDpal.o
cipele.cpp:(.text+0x6db): relocation truncated to fit: R_X86_64_PC32 against symbol `nR' defined in .bss section in /tmp/ccWVDpal.o
cipele.cpp:(.text+0x6e2): relocation truncated to fit: R_X86_64_PC32 against symbol `nR' defined in .bss section in /tmp/ccWVDpal.o
cipele.cpp:(.text+0x7ad): relocation truncated to fit: R_X86_64_PC32 against symbol `R' defined in .bss section in /tmp/ccWVDpal.o
cipele.cpp:(.text+0x7f7): relocation truncated to fit: R_X86_64_PC32 against symbol `nR' defined in .bss section in /tmp/ccWVDpal.o
cipele.cpp:(.text+0x808): relocation truncated to fit: R_X86_64_PC32 against symbol `R' defined in .bss section in /tmp/ccWVDpal.o
cipele.cpp:(.text+0x80f): additional relocation overflows omitted from the output
/usr/bin/ld: failed to convert GOTPCREL relocation; relink with --no-relax
collect2: error: ld returned 1 exit status