当前位置:网站首页>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;
}边栏推荐
- 2022 operation of simulated examination platform for melting welding and thermal cutting work license
- Bc35 & bc95 onenet mqtt (old)
- [leetcode] number of maximum consecutive ones
- Export default the exported object cannot be deconstructed, and module Differences between exports
- 【底部弹出-选择器】uniapp Picker组件——底部弹起的滚动选择器
- [bottom pop-up selector] uniapp picker component - scroll selector popped up at the bottom
- [CTF] bjdctf 2020 Bar _ Bacystack2
- Accelerator systems initiative is an independent non-profit organization
- Global and Chinese markets for power over Ethernet (POE) solutions 2022-2028: Research Report on technology, participants, trends, market size and share
- S32Kxxx bootloader之UDS bootloader
猜你喜欢

测试员8年工资变动,令网友羡慕不已:你一个月顶我一年工资

Intelligent operation and maintenance practice: banking business process and single transaction tracking

2022 high altitude installation, maintenance and removal of test question simulation test platform operation
![[leetcode] number of maximum consecutive ones](/img/70/7f3d1c8e0ab2698d98220cca911209.png)
[leetcode] number of maximum consecutive ones

RFID让固定资产盘点更快更准

2023款雷克萨斯ES产品公布,这回进步很有感

Xinniuniu blind box wechat applet source code_ Support flow realization, with complete material pictures

Creation of volume group for AIX storage management (I)

Weather forecast applet source code weather wechat applet source code

AIX存储管理之卷组的创建(一)
随机推荐
Export default the exported object cannot be deconstructed, and module Differences between exports
测试员8年工资变动,令网友羡慕不已:你一个月顶我一年工资
【底部弹出-选择器】uniapp Picker组件——底部弹起的滚动选择器
Leetcode skimming: stack and queue 03 (valid parentheses)
2022拼多多详情/拼多多商品详情/拼多多sku详情
Node——Egg 创建本地文件访问接口
Basis of deep learning neural network
测试人进阶技能:单元测试报告应用指南
I want to ask, which is the better choice for securities companies? I don't understand. Is it safe to open an account online now?
AIX存储管理之卷组的创建(一)
Cookie, session, tooken
[CTF] bjdctf 2020 Bar _ Bacystack2
"C zero foundation introduction hundred knowledge hundred examples" (73) anonymous function -- lambda expression
If the browser is accidentally closed, how does react cache the forms filled out by users?
Slf4j print abnormal stack information
2022 safety officer-b certificate examination practice questions simulated examination platform operation
Node -- add compressed file
Keepalived introduction and installation
创业团队如何落地敏捷测试,提升质量效能?丨声网开发者创业讲堂 Vol.03
Leetcode question brushing: stack and queue 07 (maximum value of sliding window)