qwopew @ 2019-11-04 19:47:40
int c[5000000],d[5000000],e[5000000],f[5000000]; int main() { int a,b; scanf("%d%d",&a,&b); int i,j; for(i=0;i<a;i++) { scanf("%d",&c[i]); } for(i=0;i<b;i++) { scanf("%d%d%d",&d[i],&e[i],&f[i]); for(j=d[i-1];j<=e[i-1];j++) { c[j]+=f[i]; } } int min=c[0]; for(i=1;i<a;i++) { if(c[i]<min) { min=c[i]; } } printf("%d",min); return 0; }
by 0x3喵酱 @ 2019-11-04 19:48:42
前排围观
by songhongyi @ 2019-11-04 19:49:09
#include "stdio.h"
int c[5000000],d[5000000],e[5000000],f[5000000];
int main()
{
int a,b;
scanf("%d%d",&a,&b);
int i,j;
for(i=0; i<a; i++)
{
scanf("%d",&c[i]);
}
for(i=0; i<b; i++)
{
scanf("%d%d%d",&d[i],&e[i],&f[i]);
for(j=d[i-1]; j<=e[i-1]; j++)
{
c[j]+=f[i];
}
}
int min=c[0];
for(i=1; i<a; i++)
{
if(c[i]<min)
{
min=c[i];
}
}
printf("%d",min);
return 0;
}
学习使用Markdown
by qwopew @ 2019-11-04 19:49:33
@songhongyi 什么啊QAQ
by Amor_Hucsy @ 2019-11-04 19:49:42
orz,这个新人不知比我强多少,第一天就切黄题,我jio得您能AK IOI CSP NOI NOIP 以及WC
by songhongyi @ 2019-11-04 19:50:38
@小紬qwq 此题正解线段树,暴力满分才怪呢
by qwopew @ 2019-11-04 19:51:59
@songhongyi 那我为什么有些错了啊QAQ,我知道TLE是超时了
by OvOAuto @ 2019-11-04 19:53:05
像我这种当年 a+b 还是就着题解写的蒟蒻
by abjfj @ 2019-11-04 19:59:43
for(i=0; i<b; i++)
{
scanf("%d%d%d",&d[i],&e[i],&f[i]);
for(j=d[i]-1; j<=e[i]-1; j++)
{
c[j]+=f[i];
}
}
我猜您是想这么写吧
by Amor_Hucsy @ 2019-11-04 20:02:44
@OvO自动机 orz 当年我开机都学不会
by qwopew @ 2019-11-04 20:04:38
@abjfj 谢谢QAQ!!