Submission #1110240

#TimeUsernameProblemLanguageResultExecution timeMemory
1110240vjudge1Growing Vegetables is Fun 5 (JOI24_vegetables5)C++17
9 / 100
116 ms6728 KiB
#include <bits/stdc++.h> using namespace std; #define ff(i, a, b) for(auto i=(a); i<=(b); ++i) #define ffr(i, b, a) for(auto i=(b); i>=(a); --i) #define nl "\n" #define ss " " #define pb emplace_back #define fi first #define se second #define sz(s) (int)s.size() #define ms(a,x) memset(a, x, sizeof (a)) #define re exit(0) #define cn continue typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef vector<int> vi; typedef vector<ll> vll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<pii> vpii; typedef vector<pll> vpll; const int mod=1e9+7; //const int mod=998244353; const int maxn=3e5+105; const int maxm=4*maxn+5; const ll inf=1e18; mt19937 ran(time(0)); mt19937_64 ran64(time(0)); void rf(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if(fopen("o.inp","r")){ freopen("o.inp","r",stdin); freopen("o.out","w",stdout); } } void add(int &x, int y) { x+=y; if(x>=mod) x-=mod; if(x<0) x+=mod; } int n, m, a[maxm], b[maxn], c[maxn]; bool getbit(int mask, int i) { return (mask>>i)&1; } bool check(int mask) { if(__builtin_popcount(mask)!=n) return 0; int cur=1; ff(i, 1, m-1) { if(getbit(mask, i)==getbit(mask, i-1)) { ++cur; if(cur>=n) return 1; } else { if(cur>=n) return 1; cur=1; } } return 0; } signed main() { rf(); cin>>n; m=n+n; ff(i, 1, m) cin>>a[i]; ff(i, 1, n) cin>>b[i]; ff(i, 1, n) cin>>c[i]; sort(b+1, b+n+1); sort(c+1, c+n+1); int ans=mod; for(int mask=1; mask<(1<<m); ++mask) { if(!check(mask)) continue; vi v0, v1; ff(i ,0, m-1) { if(getbit(mask, i)) v0.pb(a[i+1]); else v1.pb(a[i+1]); } sort(v0.begin(), v0.end()); sort(v1.begin(), v1.end()); int res=0; ff(i, 1, n) res=max(res, abs(b[i]-v0[i-1])); ff(i, 1, n) res=max(res, abs(c[i]-v1[i-1])); ans=min(ans, res); } cout<<ans<<nl; re; }

Compilation message (stderr)

Main.cpp: In function 'void rf()':
Main.cpp:41:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |         freopen("o.inp","r",stdin); freopen("o.out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~
Main.cpp:41:44: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |         freopen("o.inp","r",stdin); freopen("o.out","w",stdout);
      |                                     ~~~~~~~^~~~~~~~~~~~~~~~~~~~
#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...