제출 #679169

#제출 시각아이디문제언어결과실행 시간메모리
679169tigarGap (APIO16_gap)C++14
0 / 100
45 ms1100 KiB
#include <bits/stdc++.h> #include "gap.h" using namespace std; typedef long long ll; ll mn, mx; /*int T, N; ll call_count, subtask_num, A[100000]; static void my_assert(int k){ if (!k) exit(1); } void MinMax(long long s, long long t, long long *mn, long long *mx) { int lo = 1, hi = N, left = N+1, right = 0; my_assert(s <= t && mn != NULL && mx != NULL); while (lo <= hi){ int mid = (lo+hi)>>1; if (A[mid] >= s) hi = mid - 1, left = mid; else lo = mid + 1; } lo = 1, hi = N; while (lo <= hi){ int mid = (lo+hi)>>1; if (A[mid] <= t) lo = mid + 1, right = mid; else hi = mid - 1; } if (left > right) *mn = *mx = -1; else{ *mn = A[left]; *mx = A[right]; } if (subtask_num == 1) call_count++; else if (subtask_num == 2) call_count += right-left+2; }*/ ll findGap(int T, int N) { if(T==1) { ll up_bound=LONG_LONG_MAX, low_bound=0; MinMax(low_bound, up_bound, &mn, &mx); ll a=mn, b=mx; low_bound=mn+1; up_bound=mx-1; ll razlika=0; while(mn!=-1 and up_bound>=low_bound) { MinMax(low_bound, up_bound, &mn, &mx); if(mn!=-1 and mx!=-1) { razlika=max(razlika, max(abs(mn-a), abs(b-mx))); low_bound=mn+1; up_bound=mx-1; a=mn; b=mx; } } return razlika; } } /*int main() { cin>>T>>N; for(int i=1; i<=N; i++)cin>>A[i]; cout<<findGap(T, N); } /*1 2 1 3 4!!!!*/

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

gap.cpp:66:1: warning: "/*" within comment [-Wcomment]
   66 | /*1 2
      |  
gap.cpp: In function 'll findGap(int, int)':
gap.cpp:58:1: warning: control reaches end of non-void function [-Wreturn-type]
   58 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...