結果
問題 |
No.723 2つの数の和
|
ユーザー |
![]() |
提出日時 | 2020-03-14 20:43:21 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 21 ms / 2,000 ms |
コード長 | 464 bytes |
コンパイル時間 | 3,179 ms |
コンパイル使用メモリ | 198,332 KB |
最終ジャッジ日時 | 2025-01-09 06:54:59 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
#include<bits/stdc++.h> #define endl enjoy_codeforces using lint=long long; int main(){ std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false); lint n,X;std::cin>>n>>X; std::vector<lint>a(n); for(lint&x:a)std::cin>>x; std::sort(a.begin(),a.end()); lint ans=0; for(lint i=0,j=0,k=n-1;k>=0;k--){ for(;j<n&&a.at(j)+a.at(k)<=X;j++); for(;i<n&&a.at(i)+a.at(k)<X;i++); ans+=j-i; } std::cout<<ans<<'\n'; }