結果
問題 |
No.1882 Areas of Triangle
|
ユーザー |
![]() |
提出日時 | 2022-05-28 10:47:03 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 2,135 bytes |
コンパイル時間 | 811 ms |
コンパイル使用メモリ | 92,344 KB |
実行使用メモリ | 13,888 KB |
最終ジャッジ日時 | 2024-09-20 20:47:50 |
合計ジャッジ時間 | 4,227 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 -- * 4 |
other | AC * 3 TLE * 1 -- * 20 |
ソースコード
// 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 = 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; }