제출 #629640

#제출 시각아이디문제언어결과실행 시간메모리
629640Cyber_WolfGap (APIO16_gap)C++14
0 / 100
36 ms1104 KiB
//Contest: APIO 16 Problem 3
//Problem Name: Gap
 
 
#include <bits/stdc++.h>
#include "gap.h"
 
using namespace std;
 
 
long long findGap(int subtask, int n)
{
	vector<long long> v1, v2;
	long long first = 0, last = 1e18;
	for(int i = 0; i < n; i++)
	{
		long long mnm, mxm;
		MinMax(first, last, &mnm, &mxm);
		v1.push_back(mnm);
		if(mnm == mxm)	continue;
		v2.push_back(mxm);
		last = mnm+1;
		first = mxm-1;
		if(first >= last)	break;
	}
	long long ans = 0;
	for(int i = 1; i < v1.size(); i++)	ans = max(ans, v1[i]-v1[i-1]);
	if(v2.size())
	{
		ans = max(ans, v2.front()-v1.back());
	}
	for(int i = 1; i < v2.size(); i++)
	{
		ans = max(ans, v2[i]-v2[i-1]);
	}
	return ans;
}

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

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:27:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |  for(int i = 1; i < v1.size(); i++) ans = max(ans, v1[i]-v1[i-1]);
      |                 ~~^~~~~~~~~~~
gap.cpp:32:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |  for(int i = 1; i < v2.size(); i++)
      |                 ~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...