shenyiwen @ 2017-04-24 21:14:32
这是什么破题呀?竟然60分,网上说还要用什么差分,我的天哪
这是60分的代码
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
int main() {
ios::sync_with_stdio(false);
long long num,time;
scanf ("%lld%lld",&num,&time);
int mark[num+1];
int start;
int end;
int change;
for (int i=1;i<=num;i++) scanf ("%d",&mark[i]);
for (int i=1;i<=time;i++)
{
scanf ("%d%d%d",&start,&end,&change);
for (int j=start;j<=end;j++) mark[j]+=change;
}
sort (mark+1,mark+num+1);
printf ("%d",mark[1]);
return 0;
}
by a___ @ 2017-04-24 22:53:28
@wangyuji 你为啥用了ios::sync_with_stdio(false);还用scanf,printf
by shenyiwen @ 2017-04-25 17:56:14
什么意思
by yiyiyi @ 2017-05-15 13:13:27
。。。
by yiyiyi @ 2017-05-15 13:14:07
@wangyuji 就是用了ios一般都是用cin输入的。。。printf输出可以
by yiyiyi @ 2017-05-15 13:21:56
@wangyuji 你这个肯定超时啊。。线段树吧
by 1124828077ccj @ 2017-08-02 19:39:35
@yiyiyi 线段树绝对超时,你看看数据多大,有O(n)的算法