当前位置:网站首页>The pain of Xiao Sha
The pain of Xiao Sha
2022-07-02 00:56:00 【Learning KL & TK】

Their thinking : You can use binary search , Found The current value adds up to the maximum value
#include"bits/stdc++.h"
#define ll long long
#define pi pair<int,int>
#define inf 0x3f3f3f3f
#define _for(i,a,b) for(int i=a;i<=b;i++)
#define for_(i,a,b) for(int i=a;i<b;i++)
#define _fr(i,a,b) for(int i=a;i>=b;i--)
#define fr_(i,a,b) for(int i=a;i>b;i--)
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
const int N = 1e6+5;
const ll mod = 1e9+7;
const double lp=1.000000011;
map<int,int>mp;
ll arr[N];
void solve(){
ll n,m,x;
cin >> n >> m;
_for(i,1,n) cin >> arr[i],arr[i]%=m;
sort(arr+1,arr+1+n);
ll res = (arr[n]+arr[n-1])%m;
_for(i,1,n){
x = lower_bound(arr+i+1,arr+n,m-arr[i])-arr;
if(x != i+1) res = max(res,(arr[i]+arr[x-1])%m);
}
cout << res << endl;
}
int main()
{
IOS;
solve();
return 0;
}边栏推荐
- gradle
- Intelligent operation and maintenance practice: banking business process and single transaction tracking
- 【js通过url下载文件】
- Mitsubishi PLC FX3U pulse axis jog function block (mc_jog)
- cookie、session、tooken
- @Valid参数校验不生效
- cookie、session、tooken
- Leetcode skimming: stack and queue 05 (inverse Polish expression evaluation)
- How do Lenovo computers connect Bluetooth headsets?
- RFID让固定资产盘点更快更准
猜你喜欢

Barbie q! How to analyze the new game app?

Output results of convolution operation with multiple tensors and multiple convolution kernels

Synthetic watermelon game wechat applet source code / wechat game applet source code

Schrodinger's Japanese learning applet source code

Picture puzzle wechat applet source code_ Support multi template production and traffic master

2022 operation of simulated examination platform for melting welding and thermal cutting work license

Export default the exported object cannot be deconstructed, and module Differences between exports

Slf4j print abnormal stack information

Kyushu cloud and Intel jointly released the smart campus private cloud framework, enabling new infrastructure for education

What is ThreadLocal memory leak and how to solve it
随机推荐
cookie、session、tooken
[leetcode] number of maximum consecutive ones
Random avatar encyclopedia, multi category wechat applet source code with history_ Support traffic master
Evolution of Himalayan self-developed gateway architecture
Han Zhichao: real time risk control practice of eBay based on graph neural network
LeetCode 0241.为运算表达式设计优先级 - DFS
[cascade classifier training parameters] training Haar cascades
Synthetic watermelon game wechat applet source code / wechat game applet source code
使用 ES 实现疫情地图或者外卖点餐功能(含代码及数据)
【js通过url下载文件】
[conference resources] the Third International Conference on Automation Science and Engineering in 2022 (jcase 2022)
sso单点登录的实现。
2022 pinduoduo details / pinduoduo product details / pinduoduo SKU details
Bilstm CRF code implementation
Promise and modular programming
UDS bootloader of s32kxxx bootloader
Collection: comprehensive summary of storage knowledge
【mysql 07】GPG key retrieval failed: “Couldn‘t open file /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022“
Global and Chinese market of safety detection systems 2022-2028: Research Report on technology, participants, trends, market size and share
New version of free mobile phone, PC, tablet, notebook four terminal Website thumbnail display diagram online one click to generate website source code