QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#460552#6857. Easy problem IIaccgjAC ✓4152ms5444kbC++14795b2024-07-01 20:25:432024-07-01 20:25:43

Judging History

你现在查看的是最新测评结果

  • [2024-07-01 20:25:43]
  • 评测
  • 测评结果:AC
  • 用时:4152ms
  • 内存:5444kb
  • [2024-07-01 20:25:43]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

char *p1,*p2,buf[1000001];
#define nc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++)
inline int read()
{
	int x=0;char ch=nc();
	while(ch<'0' or ch>'9')ch=nc();
	while(ch>='0' and ch<='9')x=(x<<3)+(x<<1)+ch-'0',ch=nc();
	return x;
}

int t;

int n,m;

long long a[1000001];


int main()
{
	t=read();
	while(t--)
	{
		n=read();m=read();
		
		for(int i=1;i<=n;i++)a[i]=read();
		
		while(m--)
		{
			int op=read();
			if(op==1)
			{
				int l=read(),r=read(),x=read();
				
				for(int i=l;i<=r;++i)a[i]=((a[i]<x)?(x-a[i]):(a[i]+x));
			}
			else
			{
				int l=read(),r=read();
				long long x=0;
				for(int i=l;i<=r;++i)x+=a[i];
				printf("%lld\n",x);
			}
		}
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 4152ms
memory: 5444kb

input:

1
100000 100000
9994250 1 9999152 1 9996205 1 9993920 1 9992936 1 9999312 1 9994863 1 9999950 1 9994702 1 9998302 1 9997460 1 9995584 1 9990858 1 9995764 1 9992400 1 9992970 1 9993486 1 9992200 1 9991250 1 9990336 1 9994212 1 9992704 1 9999400 1 9994826 1 9996272 1 9995920 1 9994960 1 9996400 1 9990...

output:

474104664177
469903014249
480933011291
483822399944
484396591822
485195157450
476873328231
500050522935
490495899612
455001143708
459350186600
463088605817
452789422852
457530804729
478921256445
483860248443
460953094343
461203887676
471567676461
499102979676
483610787357
490750641096
468023668995
4...

result:

ok 85563 lines