当前位置:网站首页>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;
}边栏推荐
- Summary of Aix storage management
- Entrepreneurship is a little risky. Read the data and do a business analysis
- 【微信授权登录】uniapp开发小程序,实现获取微信授权登录功能
- Kuberntes cloud native combat high availability deployment architecture
- Global and Chinese markets for freight and logistics 2022-2028: Research Report on technology, participants, trends, market size and share
- What skills does an excellent software tester need to master?
- Leetcode skimming: binary tree 02 (middle order traversal of binary tree)
- BiLSTM-CRF代码实现
- Creating logical volumes and viewing and modifying attributes for AIX storage management
- Node——生成微信权限验证配置
猜你喜欢

2022 operation of simulated examination platform for melting welding and thermal cutting work license
![[eight sorts ④] merge sort, sort not based on comparison (count sort, cardinal sort, bucket sort)](/img/0d/22f3f65ab9422383df9a55d0724d59.jpg)
[eight sorts ④] merge sort, sort not based on comparison (count sort, cardinal sort, bucket sort)

Entrepreneurship is a little risky. Read the data and do a business analysis

Kuberntes cloud native combat high availability deployment architecture

PLC Analog input analog conversion FB s_ ITR (Mitsubishi FX3U)

excel数据透视表

The 8-year salary change of testers makes netizens envy it: you pay me one year's salary per month

XMind思维导图

With the acquisition of Xilinx, AMD is more than "walking on two legs" | Jiazi found

Iclr2022 | spherenet and g-spherenet: autoregressive flow model for 3D molecular graph representation and molecular geometry generation
随机推荐
JS——图片转base码 、base转File对象
Accelerator systems initiative is an independent non-profit organization
【微信授权登录】uniapp开发小程序,实现获取微信授权登录功能
2022 pinduoduo details / pinduoduo product details / pinduoduo SKU details
Global and Chinese markets for the application of artificial intelligence in security, public security and national security 2022-2028: Research Report on technology, participants, trends, market size
gradle
2022 safety officer-a certificate examination questions and online simulation examination
Some understandings of graph convolution neural network r-gcn considering relations and some explanations of DGL official code
Barbie q! How to analyze the new game app?
AIX存储管理之总结篇
Cookie, session, tooken
【会议资源】2022年第三届自动化科学与工程国际会议(JCASE 2022)
Zak's latest "neural information transmission", with slides and videos
Global and Chinese markets for freight and logistics 2022-2028: Research Report on technology, participants, trends, market size and share
Promise and modular programming
sso单点登录的实现。
Leetcode skimming: binary tree 01 (preorder traversal of binary tree)
Leetcode skimming: binary tree 02 (middle order traversal of binary tree)
BiLSTM-CRF代码实现
Collection: comprehensive summary of storage knowledge