当前位置:网站首页>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;
}边栏推荐
- 程序员该如何更好的规划自己的职业发展?
- Xinniuniu blind box wechat applet source code_ Support flow realization, with complete material pictures
- DTL dephossite | prediction method of dephosphorylation sites based on Transfer Learning
- 【微信授权登录】uniapp开发小程序,实现获取微信授权登录功能
- 工作中非常重要的测试策略,你大概没注意过吧
- Bc35 & bc95 onenet mqtt (old)
- Leetcode skimming: stack and queue 02 (realizing stack with queue)
- 股票开户哪个证券公司比较安全
- What is ThreadLocal memory leak and how to solve it
- BiLSTM-CRF代码实现
猜你喜欢

Random avatar encyclopedia, multi category wechat applet source code with history_ Support traffic master

Iclr2022 | spherenet and g-spherenet: autoregressive flow model for 3D molecular graph representation and molecular geometry generation

Friends circle community program source code sharing

You probably haven't noticed the very important testing strategy in your work

gradle

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

Keepalived introduction and installation

Some understandings of graph convolution neural network r-gcn considering relations and some explanations of DGL official code

BPR (Bayesian personalized sorting)

【八大排序③】快速排序(动图演绎Hoare法、挖坑法、前后指针法)
随机推荐
Use es to realize epidemic map or take out order function (including code and data)
Leetcode skimming: stack and queue 02 (realizing stack with queue)
Global and Chinese market of collaborative applications 2022-2028: Research Report on technology, participants, trends, market size and share
【八大排序①】插入排序(直接插入排序、希尔排序)
RFID makes the inventory of fixed assets faster and more accurate
Slf4j print abnormal stack information
How to reflect and solve the problem of bird flight? Why are planes afraid of birds?
Schrodinger's Japanese learning applet source code
Global and Chinese markets of beverage seasoning systems 2022-2028: Research Report on technology, participants, trends, market size and share
Powerful calendar wechat applet source code - support the main mode of doing more traffic
[opencv450] hog+svm and hog+cascade for pedestrian detection
【会议资源】2022年第三届自动化科学与工程国际会议(JCASE 2022)
How to extract login cookies when JMeter performs interface testing
一名优秀的软件测试人员,需要掌握哪些技能?
2022 high altitude installation, maintenance and removal of test question simulation test platform operation
使用 ES 实现疫情地图或者外卖点餐功能(含代码及数据)
Node -- egg implements the interface of uploading files
What skills does an excellent software tester need to master?
BPR (Bayesian personalized sorting)
Excel PivotTable