提出 #68760969


ソースコード 拡げる

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=2e5+5;
int a[N],b[N]; 
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n,q;
	cin>>n>>q;
	int ans=0;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=n;i++) cin>>b[i],ans+=min(a[i],b[i]);
	while(q--){
		char c;
		int x,v;
		cin>>c>>x>>v;
		if(c=='A'){
			int mn=min(a[x],b[x]);
			if(mn==a[x]){
				if(v<b[x]) ans=ans-a[x]+v;
				else ans=ans-a[x]+b[x];
			}
			else{
				if(v<b[x]) ans=ans-b[x]+v;
			}
			a[x]=v;
		}
		else{
			int mn=min(a[x],b[x]);
			if(mn==b[x]){
				if(v<a[x]) ans=ans-b[x]+v;
				else ans=ans-b[x]+a[x];
			}
			else{
				if(v<a[x]) ans=ans-a[x]+v;
			}
			b[x]=v;
		}
		cout<<ans<<'\n';
	}
	return 0;
}

提出情報

提出日時
問題 C - Sum of Min Query
ユーザ a_computers_xh
言語 C++ 17 (gcc 12.2)
得点 300
コード長 775 Byte
結果 AC
実行時間 63 ms
メモリ 6768 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 300 / 300
結果
AC × 3
AC × 23
セット名 テストケース
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 1 ms 3604 KiB
00_sample_01.txt AC 1 ms 3608 KiB
00_sample_02.txt AC 1 ms 3504 KiB
01_random_00.txt AC 1 ms 3496 KiB
01_random_01.txt AC 62 ms 6768 KiB
01_random_02.txt AC 54 ms 6472 KiB
01_random_03.txt AC 29 ms 5120 KiB
01_random_04.txt AC 59 ms 6300 KiB
01_random_05.txt AC 27 ms 5432 KiB
01_random_06.txt AC 47 ms 4976 KiB
01_random_07.txt AC 16 ms 4944 KiB
01_random_08.txt AC 62 ms 6636 KiB
01_random_09.txt AC 59 ms 6620 KiB
01_random_10.txt AC 61 ms 6576 KiB
01_random_11.txt AC 55 ms 6584 KiB
01_random_12.txt AC 62 ms 6616 KiB
01_random_13.txt AC 63 ms 6584 KiB
01_random_14.txt AC 62 ms 6748 KiB
01_random_15.txt AC 62 ms 6612 KiB
01_random_16.txt AC 61 ms 6572 KiB
01_random_17.txt AC 62 ms 6632 KiB
01_random_18.txt AC 59 ms 6304 KiB
01_random_19.txt AC 63 ms 6648 KiB