제출 #503960

#제출 시각아이디문제언어결과실행 시간메모리
503960Carmel_Ab1Gap (APIO16_gap)C++17
83.51 / 100
107 ms11956 KiB
#include <bits/stdc++.h> using namespace std; #include "gap.h" typedef long long ll; typedef vector<ll> vl; #define all(x) x.begin(),x.end() #define pb push_back ll ceil(ll a,ll b){return (a+b-1)/b;} ll findGap(int T, int n){ ll L=0,R=1e18; vl a; if(T==1){ int i=0; while(2*i<n){ MinMax(L,R,&L,&R); a.pb(L); a.pb(R); L++,R--; i++; } if(L==R && L!=-1) a.pb(L); ll ans=0; sort(all(a)); for(int i=0; i+1<a.size(); i++) ans=max(ans,a[i+1]-a[i]); return ans; } MinMax(0,1e18,&L,&R); ll block=ceil(R-L+1,n); ll ans=0; multiset<ll>s; for(int i=0; i<n; i++){ ll l=L+i*block; ll r=l+block-1; while(l<r){ MinMax(l,r,&l,&r); if(l==-1)break; a.pb(l); a.pb(r); s.insert(l); s.insert(r); ans=max(ans,r-(*(--s.lower_bound(r)))); if(s.upper_bound(l)!=s.end()) ans=max(ans,*s.upper_bound(l)-l); l++,r--; if(r-l<=ans)break; } if(l==r && l!=-1) a.pb(l); } sort(all(a)); for(int i=0; i+1<a.size(); i++) ans=max(ans,a[i+1]-a[i]); return ans; }

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

gap.cpp: In function 'll findGap(int, int)':
gap.cpp:29:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |         for(int i=0; i+1<a.size(); i++)
      |                      ~~~^~~~~~~~~
gap.cpp:65:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |     for(int i=0; i+1<a.size(); i++)
      |                  ~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...