Submission #2123465


Source Code Expand

#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
#define N 200010
ll n,q,a[N],b[N];
map<ll,ll> mp;
void Erase(ll x){
    mp[x]--;
    if(mp[x]==0)mp.erase(x);
}
int main(){
    cin>>n>>q;
    lol(i,2*n)cin>>a[i];
    lol(i,2*n)cin>>b[i];
    
    ll sum=a[0]+a[2*n-1];
    ll cnt=0;
    for(int i=1;i<=2*n-2;i++){
	sum+=max(a[i],b[i]);
	if(a[i]>b[i]){
	    mp[a[i]-b[i]]++;
	    cnt++;
	}
	else mp[b[i]-a[i]]++;
    }
    
    lol(u,q){
	ll p,x,y;
	cin>>p>>x>>y;
	p--;
	if(p==0||p==2*n-1){
	    sum=sum-a[0]+x;
	}
	else{
	    sum-=max(a[p],b[p]);
	    sum+=max(x,y);
	    
	    if(a[p]>b[p]){
		Erase(a[p]-b[p]);
		cnt--;
	    }
	    else Erase(b[p]-a[p]);
	    
	    if(x>y){
		mp[x-y]++;
		cnt++;
	    }
	    else mp[y-x]++;
	}
	a[p]=x,b[p]=y;
	ll ans=sum;
	if(cnt%2==1){
	    ans-=mp.begin()->first;
	}
	cout<<ans<<endl;
    }
    return 0;
}

Submission Info

Submission Time
Task C - Paired Parentheses
User ynymxiaolongbao
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1051 Byte
Status WA
Exec Time 604 ms
Memory 17280 KB

Judge Result

Set Name Sample Subtask1 Subtask2 All
Score / Max Score 0 / 0 0 / 200 0 / 300 0 / 200
Status
AC × 2
AC × 6
WA × 8
AC × 13
WA × 2
AC × 25
WA × 18
Set Name Test Cases
Sample 00_example_01.txt, 00_example_02.txt
Subtask1 00_example_01.txt, s1_01.txt, s1_02.txt, s1_03.txt, s1_04.txt, s1_05.txt, s1_06.txt, s1_07.txt, s1_08.txt, s1_09.txt, s1_10.txt, s1_11.txt, s1_12.txt, s1_13.txt
Subtask2 s2_14.txt, s2_15.txt, s2_16.txt, s2_17.txt, s2_18.txt, s2_19.txt, s2_20.txt, s2_21.txt, s2_22.txt, s2_23.txt, s2_24.txt, s2_25.txt, s2_26.txt, s2_27.txt, s2_28.txt
All 00_example_01.txt, 00_example_02.txt, s1_01.txt, s1_02.txt, s1_03.txt, s1_04.txt, s1_05.txt, s1_06.txt, s1_07.txt, s1_08.txt, s1_09.txt, s1_10.txt, s1_11.txt, s1_12.txt, s1_13.txt, s2_14.txt, s2_15.txt, s2_16.txt, s2_17.txt, s2_18.txt, s2_19.txt, s2_20.txt, s2_21.txt, s2_22.txt, s2_23.txt, s2_24.txt, s2_25.txt, s2_26.txt, s2_27.txt, s2_28.txt, s3_29.txt, s3_30.txt, s3_31.txt, s3_32.txt, s3_33.txt, s3_34.txt, s3_35.txt, s3_36.txt, s3_37.txt, s3_38.txt, s3_39.txt, s3_40.txt, s3_41.txt
Case Name Status Exec Time Memory
00_example_01.txt AC 1 ms 256 KB
00_example_02.txt AC 1 ms 256 KB
s1_01.txt AC 1 ms 256 KB
s1_02.txt WA 1 ms 256 KB
s1_03.txt WA 1 ms 256 KB
s1_04.txt AC 1 ms 256 KB
s1_05.txt AC 1 ms 256 KB
s1_06.txt AC 1 ms 256 KB
s1_07.txt AC 1 ms 256 KB
s1_08.txt WA 1 ms 256 KB
s1_09.txt WA 1 ms 256 KB
s1_10.txt WA 1 ms 256 KB
s1_11.txt WA 1 ms 256 KB
s1_12.txt WA 1 ms 256 KB
s1_13.txt WA 1 ms 256 KB
s2_14.txt AC 8 ms 896 KB
s2_15.txt AC 9 ms 1024 KB
s2_16.txt AC 133 ms 9728 KB
s2_17.txt AC 105 ms 8192 KB
s2_18.txt AC 193 ms 15872 KB
s2_19.txt AC 191 ms 13824 KB
s2_20.txt AC 193 ms 13824 KB
s2_21.txt AC 199 ms 13824 KB
s2_22.txt AC 8 ms 896 KB
s2_23.txt WA 9 ms 1024 KB
s2_24.txt AC 9 ms 896 KB
s2_25.txt AC 243 ms 15872 KB
s2_26.txt WA 243 ms 15872 KB
s2_27.txt AC 245 ms 16000 KB
s2_28.txt AC 244 ms 15872 KB
s3_29.txt AC 196 ms 7808 KB
s3_30.txt WA 300 ms 4992 KB
s3_31.txt AC 162 ms 11136 KB
s3_32.txt AC 501 ms 12032 KB
s3_33.txt AC 199 ms 7680 KB
s3_34.txt AC 604 ms 15232 KB
s3_35.txt WA 588 ms 15232 KB
s3_36.txt WA 584 ms 17280 KB
s3_37.txt WA 579 ms 17280 KB
s3_38.txt WA 573 ms 17280 KB
s3_39.txt WA 580 ms 17280 KB
s3_40.txt WA 242 ms 1408 KB
s3_41.txt WA 236 ms 1408 KB