結果
| 問題 | 
                            No.1882 Areas of Triangle
                             | 
                    
| ユーザー | 
                             ramia777
                         | 
                    
| 提出日時 | 2022-05-28 10:42:08 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                TLE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 2,071 bytes | 
| コンパイル時間 | 943 ms | 
| コンパイル使用メモリ | 91,020 KB | 
| 実行使用メモリ | 13,824 KB | 
| 最終ジャッジ日時 | 2024-09-20 20:46:10 | 
| 合計ジャッジ時間 | 7,212 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | TLE * 1 -- * 4 | 
| other | -- * 24 | 
ソースコード
// 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;      //境界は前半にある
		}
		else
		{
			L = key;       //境界は後半にある
		}
		//中央値を更新
		key = FCEIL(L + R, 2);//切り上げ
	
		if (R - L < 1)
			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;
}
            
            
            
        
            
ramia777