結果

問題 No.1882 Areas of Triangle
ユーザー ramia777ramia777
提出日時 2022-05-28 10:51:05
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 230 ms / 2,000 ms
コード長 2,174 bytes
コンパイル時間 733 ms
コンパイル使用メモリ 92,040 KB
実行使用メモリ 4,980 KB
最終ジャッジ日時 2023-10-20 22:47:55
合計ジャッジ時間 2,073 ms
ジャッジサーバーID
(参考情報)
judge10 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 230 ms
4,716 KB
testcase_05 AC 93 ms
4,980 KB
testcase_06 AC 46 ms
4,464 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 3 ms
4,348 KB
testcase_19 AC 7 ms
4,348 KB
testcase_20 AC 7 ms
4,348 KB
testcase_21 AC 7 ms
4,348 KB
testcase_22 AC 11 ms
4,348 KB
testcase_23 AC 36 ms
4,348 KB
testcase_24 AC 21 ms
4,348 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 2 ms
4,348 KB
testcase_28 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// yukicodr
//No.1882




//二次元可変配列
//vector <vector <int>> mass;
//vector <vector <int>> memo;
//vector <int> memo;


//#include "stdafx.h"
#include <iostream>
#include <vector>
#include <list>//list
#include <set> //tree
#include <map> //連想配列
#include <unordered_set> //hash
#include <unordered_map> //hash
#include <algorithm>
#include <iomanip>
#include <cstring>
//#include <bits/stdc++.h>

using namespace std;

#define FMAX(a,b)  ((a)>(b)?(a):(b))
#define FMIN(a,b)  ((a)<(b)?(a):(b))
#define FCEIL(a,b)  ((a)+(b)-1)/(b)

#define FOR(x,to) for(x=0;x<to;x++)
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))


typedef unsigned long long ULL;
typedef signed long long SLL;





//昇順
int compare_up(const int * a, const int *b)
{
	if (*a > *b)
		return (1);
	else if (*a < *b)
		return (-1);
	return (0);
}

//降順
int compare_down(const ULL * a, const ULL *b)
{
	if (*a > *b)
		return (-1);
	else if (*a < *b)
		return (1);
	return (0);
}

int solve(int i, ULL index_flag)
{

	return 0;
}

ULL N, K;
ULL a[100005];

int main()
{

	cin >> N;
	cin >> K;
	for (int i=0;i<N;i++)
	{
		cin >> a[i];
	}

	//降順に並び替える
	qsort(a, N, sizeof(ULL), (int(*)(const void*, const void*))compare_down);

	ULL ans = 0;
	ULL L = 0;
	ULL R = N-1;
	ULL key = (L + R) / 2;

	ULL S = 0;
	
	K <<= 1;
	while (1)
	{
		S = (a[key] * a[0]);
		if (K > S)  //降順で並んだ数列の中央で計算した面積がターゲットより小さい場合
		{
			R = key;      //境界は前半にある

			//中央値を更新
			key = (L + R)/2;//切り下げ
		}
		else
		{
			L = key;       //境界は後半にある

			//中央値を更新
			//key = (L + R) / 2;//切り下げ
			key = FCEIL(L + R, 2);//切り上げ
		}

		

	
		if (R - L < 2)
			break;
	}

	//cout << (key + 1)*(key+1) << endl;
	

	ULL single = 0, twice = 0;

	for (int i = key; i >= 0; i--)
	{
		for (int j = i; j >= 0; j--)
		{

			S = (a[i] * a[j]);

			if (S < K)
			{
				if (j == i)
					single++;
				else
					twice++;
			}
			else
				break;
		}
	}


	cout << (key + 1)*(key + 1) - (single + twice*2) << endl;
	

	//getchar();
	return 0;

}

0