제출 #888320

#제출 시각아이디문제언어결과실행 시간메모리
88832012345678Gap (APIO16_gap)C++17
30 / 100
3095 ms8848 KiB
#include "gap.h" #include <bits/stdc++.h> using namespace std; #define ll long long long long findGap(int T, int N) { if (T==1) { ll x=0, y=1e18, a, b, idx=0, mx=0; vector<ll> v; while (v.size()<N) { MinMax(x, y, &a, &b); if (a==b) v.push_back(a); else v.push_back(a), v.push_back(b); x=a+1; y=b-1; } sort(v.begin(), v.end()); for (int i=1; i<v.size(); i++) mx=max(mx, v[i]-v[i-1]); return mx; } else { ll x=0, y=1e18, mn, mx, mmn, mmx, res=0; vector<ll> v; MinMax(x, y, &mmn, &mmx); if (mmx-mmn+1<N+1) return 1; ll gap=(mmx-mmn+1)/(N+1); for (int i=mmn; i<=mmx; i+=gap) { MinMax(i, i+gap-1, &mn, &mx); if (mn==-1) continue; v.push_back(mn); if (mn!=mx) v.push_back(mx); if (v.size()>2*N) cout<<1/0; } sort(v.begin(), v.end()); for (int i=1; i<v.size(); i++) res=max(res, v[i]-v[i-1]); return res; } }

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

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:15:24: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   15 |         while (v.size()<N)
      |                ~~~~~~~~^~
gap.cpp:23:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |         for (int i=1; i<v.size(); i++) mx=max(mx, v[i]-v[i-1]);
      |                       ~^~~~~~~~~
gap.cpp:13:31: warning: unused variable 'idx' [-Wunused-variable]
   13 |         ll x=0, y=1e18, a, b, idx=0, mx=0;
      |                               ^~~
gap.cpp:39:25: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   39 |             if (v.size()>2*N) cout<<1/0;
      |                 ~~~~~~~~^~~~
gap.cpp:39:38: warning: division by zero [-Wdiv-by-zero]
   39 |             if (v.size()>2*N) cout<<1/0;
      |                                     ~^~
gap.cpp:42:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |         for (int i=1; i<v.size(); i++) res=max(res, v[i]-v[i-1]);
      |                       ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...