結果

問題 No.1882 Areas of Triangle
ユーザー ramia777ramia777
提出日時 2022-05-28 10:10:39
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,941 bytes
コンパイル時間 1,299 ms
コンパイル使用メモリ 92,012 KB
実行使用メモリ 4,956 KB
最終ジャッジ日時 2023-10-20 22:46:58
合計ジャッジ時間 2,490 ms
ジャッジサーバーID
(参考情報)
judge10 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 WA -
testcase_04 AC 240 ms
4,692 KB
testcase_05 AC 96 ms
4,956 KB
testcase_06 WA -
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 WA -
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
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 8 ms
4,348 KB
testcase_20 AC 8 ms
4,348 KB
testcase_21 WA -
testcase_22 AC 12 ms
4,348 KB
testcase_23 AC 38 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 1 ms
4,348 KB
testcase_28 WA -
権限があれば一括ダウンロードができます

ソースコード

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 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;      //境界は前半にある
		}
		else
		{
			L = key;       //境界は後半にある
		}

		//中央値を更新
		key = (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