結果
問題 |
No.3128 Isosceles Triangle
|
ユーザー |
|
提出日時 | 2025-04-28 20:22:28 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 324 ms / 2,500 ms |
コード長 | 538 bytes |
コンパイル時間 | 2,705 ms |
コンパイル使用メモリ | 203,508 KB |
実行使用メモリ | 16,680 KB |
最終ジャッジ日時 | 2025-04-28 20:22:38 |
合計ジャッジ時間 | 8,958 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:11:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 11 | scanf("%d",&n); | ~~~~~^~~~~~~~~ main.cpp:16:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 16 | scanf("%d",&x); | ~~~~~^~~~~~~~~
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int INF=0x3f3f3f3f; const ll LLINF=0x3f3f3f3f3f3f3f3fLL; const int MAX=1e7+10; int main() { int n,i,x; ll ans,cnt; scanf("%d",&n); map<int,int> mp; vector<int> res; for(i=1;i<=n;i++) { scanf("%d",&x); mp[x]++; res.push_back(x); } sort(res.begin(),res.end()); ans=0; for(auto &it:mp) { cnt=lower_bound(res.begin(),res.end(),it.first*2)-res.begin(); cnt-=it.second; ans+=cnt*(it.second*(it.second-1)/2); } printf("%lld\n",ans); return 0; }