社区讨论
厌氧代码?
P3353在你窗外闪耀的星星参与者 3已保存回复 7
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 7 条
- 当前快照
- 1 份
- 快照标识符
- @m2yqtx5e
- 此快照首次捕获于
- 2024/11/01 21:01 去年
- 此快照最后确认于
- 2025/11/04 15:35 4 个月前
被一道橙题硬控...
突然想关闭试试
结果...
代码如下,求解释。
CPP#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#ifdef _WIN32
#define getchar_unlocked getchar
#define putchar_unlocked putchar
#else
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif
// #define x first
// #define y second
#define mem(a,b) memset((a),(b),sizeof(a))
constexpr int L=1*1e6+10; // L!=1e9+10
typedef long long LL;
// typedef unsigned long long ULL;
// typedef std::pair<int,int> PII;
// typedef std::priority_queue<int,std::vector<int>,std::greater<int> > P_Q;
// typedef std::priority_queue<int,std::vector<int>,std::less<int> > _P_Q;
// typedef __int128 INT
// constexpr int N=;
// constexpr int M=;
constexpr int inf=0x3f3f3f3f;
constexpr signed err=-1;
constexpr double eps=1e-8;
const double pi=acos(-1.0);
constexpr int dx[]={0, 0, 1,-1, 1, 1,-1,-1};
constexpr int dy[]={1,-1, 0, 0, 1,-1,-1, 1};
// constexpr LL mod=1e9+7;
#define I using
#define AK namespace
#define NOIP_2024 std
I AK NOIP_2024;
template<typename T>
void debug(string name="(NaN)",vector<T> v={-1})
{
cout<<"\n***"<<name<<"***\n";
for(typename vector<T>::const_iterator it=v.begin();it!=v.end();it++)
cout<<*it<<' ';
cout<<"\n****************\n";
}
inline LL read()
{
int f=1;
LL x=0;
char c=getchar_unlocked();
while(c<'0'||c>'9')
{
if(c=='-')
f=-1;
c=getchar_unlocked();
}
while('0'<=c&&c<='9')
{
x=(x<<3)+(x<<1)+(c^48);
c=getchar_unlocked();
}
return f*x;
}
inline void _write(LL x)
{
if(x<0)
{
putchar_unlocked('-');
x=-x;
}
if(x>9)
_write(x/10);
putchar_unlocked(x%10+'0');
return;
}
inline void write(LL x,short op=0)/* op>0:x+Space;
op==0:x;
op<0:x+endl.*/
{
_write(x);
if(op==0)
return;
else if(op>0)
putchar_unlocked(' ');
else
putchar_unlocked('\n');
return;
}
inline void write_s(string s)
{
int len=s.size();
for(int i=0;i<len;i++)
putchar_unlocked(s[i]);
}
int n,w;
int st[L],len=1;
int s[L],maxn=err;
//#define ONLINE_JUDGE
signed main()
{
// #ifndef ONLINE_JUDGE
// freopen("star.in","r",stdin);
// freopen("star.out","w",stdout);
// #endif
n=read();
w=read();
for(int i=1;i<=n;i++)
{
int x=read();
int b=read();
st[x]+=b;
len=max(len,x);
}
for(int i=1;i<=len;i++)
{
s[i]=s[i-1]+st[i];
}
for(int i=1;i<=len;i++)
{
maxn=max(maxn,s[i]-s[i-w]);
}
write(maxn,err);
return 0;
}
回复
共 7 条回复,欢迎继续交流。
正在加载回复...