为啥没人用数组做?

P2068 统计和

#include<bits/stdc++.h> using namespace std; int a[1000001]; int xxx(int x1,int x2); int yyy(int x1,int x2); int ttt[100001]; int q__1=1; int main() { int n,a1,a2; char pp; int w; cin>>n>>w; for(int i=1;i<=w;i++) { cin>>pp>>a1>>a2; if(pp=='x') { xxx(a1,a2); } else { yyy(a1,a2); } } for(int i=1;i<=q__1-1;i++) { cout<<ttt[i]<<endl; } return 0; } int xxx(int x1,int x2) { a[x1]=a[x1]+x2; return 0; } int yyy(int x1,int x2) { long long int sum=0; for(x1;x1<=x2;x1++) { sum=sum+a[x1]; } ttt[q__1]=sum; q__1++; return 0; } 附玄学代码
by gjh303987897 @ 2019-04-14 10:11:37


@[gjh303987897](/space/show?uid=181715) 这种题的正解本来就不是数组 数据一大, 你的代码就$GG$
by CeLaMbDa @ 2019-04-14 10:17:11


希更展?使MD!
by yummy @ 2019-08-13 22:31:51


@[gjh303987897](/user/181715) 数据太弱,按照范围应该是1e9的,你试试能过吗
by Suuon_Kanderu @ 2020-03-13 10:03:59


|