Submission #2095757
Source Code Expand
#include "bits/stdc++.h"
using namespace std;
const long long mod = 1000000007;
const int maxn = 222222;
long long a[maxn], b[maxn];
long long tr[2][maxn<<2];
int n;
void modify(int id, int l, int r, int x, int aa, int bb){
if(l == r){
if(l == 1 || l == n){
tr[0][id] = aa;
tr[1][id] = -(1ll<<60);
} else {
tr[0][id] = aa;
tr[1][id] = bb;
}
} else {
int mid = (l + r)>>1;
if(x <= mid) modify(id<<1, l, mid, x, aa, bb);
else modify(id<<1|1, mid + 1, r, x, aa, bb);
tr[0][id] = max(tr[0][id<<1] + tr[0][id<<1|1], tr[1][id<<1] + tr[1][id<<1|1]);
tr[1][id] = max(tr[1][id<<1] + tr[0][id<<1|1], tr[0][id<<1] + tr[1][id<<1|1]);
}
}
int main(){
int q;
scanf("%d %d", &n, &q);
n *= 2;
for(int e = 1; e <= n; e++){
scanf("%lld", a + e);
}
for(int e = 1; e <= n; e++){
scanf("%lld", b + e);
}
for(int e = 1; e <= n; e++){
modify(1, 1, n, e, a[e], b[e]);
}
while(q--){
int x, aa, bb;
scanf("%d %d %d", &x, &aa, &bb);
modify(1, 1, n, x, aa, bb);
printf("%lld\n", tr[0][1]);
}
return 0;
}
Submission Info
Submission Time |
|
Task |
C - Paired Parentheses |
User |
FMota |
Language |
C++14 (GCC 5.4.1) |
Score |
700 |
Code Size |
1246 Byte |
Status |
AC |
Exec Time |
137 ms |
Memory |
18944 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:27:27: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d", &n, &q);
^
./Main.cpp:30:29: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld", a + e);
^
./Main.cpp:33:29: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld", b + e);
^
./Main.cpp:40:40: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d %d", &x, &aa, &bb);
^
Judge Result
Set Name |
Sample |
Subtask1 |
Subtask2 |
All |
Score / Max Score |
0 / 0 |
200 / 200 |
300 / 300 |
200 / 200 |
Status |
|
|
|
|
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 |
2 ms |
6400 KB |
00_example_02.txt |
AC |
2 ms |
6400 KB |
s1_01.txt |
AC |
2 ms |
6400 KB |
s1_02.txt |
AC |
2 ms |
6400 KB |
s1_03.txt |
AC |
2 ms |
6400 KB |
s1_04.txt |
AC |
2 ms |
6400 KB |
s1_05.txt |
AC |
2 ms |
6400 KB |
s1_06.txt |
AC |
2 ms |
6400 KB |
s1_07.txt |
AC |
2 ms |
6400 KB |
s1_08.txt |
AC |
2 ms |
6400 KB |
s1_09.txt |
AC |
2 ms |
6400 KB |
s1_10.txt |
AC |
2 ms |
6400 KB |
s1_11.txt |
AC |
2 ms |
6400 KB |
s1_12.txt |
AC |
2 ms |
6400 KB |
s1_13.txt |
AC |
2 ms |
6400 KB |
s2_14.txt |
AC |
5 ms |
6656 KB |
s2_15.txt |
AC |
5 ms |
6656 KB |
s2_16.txt |
AC |
48 ms |
16896 KB |
s2_17.txt |
AC |
40 ms |
12672 KB |
s2_18.txt |
AC |
69 ms |
17408 KB |
s2_19.txt |
AC |
69 ms |
17408 KB |
s2_20.txt |
AC |
69 ms |
17408 KB |
s2_21.txt |
AC |
69 ms |
17408 KB |
s2_22.txt |
AC |
5 ms |
6656 KB |
s2_23.txt |
AC |
5 ms |
6656 KB |
s2_24.txt |
AC |
5 ms |
6656 KB |
s2_25.txt |
AC |
74 ms |
17408 KB |
s2_26.txt |
AC |
74 ms |
17408 KB |
s2_27.txt |
AC |
76 ms |
17408 KB |
s2_28.txt |
AC |
74 ms |
17408 KB |
s3_29.txt |
AC |
52 ms |
12928 KB |
s3_30.txt |
AC |
58 ms |
8320 KB |
s3_31.txt |
AC |
57 ms |
17152 KB |
s3_32.txt |
AC |
110 ms |
18304 KB |
s3_33.txt |
AC |
52 ms |
12928 KB |
s3_34.txt |
AC |
130 ms |
18944 KB |
s3_35.txt |
AC |
130 ms |
18944 KB |
s3_36.txt |
AC |
132 ms |
18944 KB |
s3_37.txt |
AC |
137 ms |
18944 KB |
s3_38.txt |
AC |
133 ms |
18944 KB |
s3_39.txt |
AC |
132 ms |
18944 KB |
s3_40.txt |
AC |
40 ms |
7168 KB |
s3_41.txt |
AC |
40 ms |
7168 KB |