D. Exams time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vasiliy has an exam period which will continue for n days. He has to pass exams on m subjects. Subjects are numbered from 1 to m. Ab…
二分答案,贪心判断,洛谷上要开long long #include<iostream> #include<cstdio> using namespace std; const int N=50005; int n,m,a[N],b[N]; int read() { int r=0,f=1; char p=getchar(); while(p>'9'||p<'0') { if(p=='-') f=-1; p=getchar(); } while(p>='0'&…
二分答案w,然后判断的时候维护一个mx,扫描序列,先更新mx=max(mx,a[i]-w),然后如果a[i]+w<mx的话就是说这个位置即使升到极限并且前面降到极限也不能符合条件了 #include<iostream> #include<cstdio> using namespace std; const int N=5000005; int n,sa,sb,sc,sd,a[N],mod; int clc(int x) { return (((1ll*sa*x%mod*x%m…
#include<iostream> #include<cstdio> #include<algorithm> using namespace std; const int N=1000005; int n,a[N],b[N]; long long m,f[N],s[N]; int ok(int w) { long long ans=0; for(int i=1;i<=n;i++) b[i]=a[i]; for(int i=2;i<=n;i++) if(b[…
题目链接: B. Skills time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Lesha plays the recently published new version of the legendary game hacknet. In this version character skill mechanism was…