Submission #68745517


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define ff first
#define ss second
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define f(i,x,y) for(int i=x;i<y;i++)
#define f2(i,x,y) for(int i=x;i>=y;i--)
#define pii pair<int,int>
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int MOD =1000000007;
const int INF = 1e18;
const int N = 2e5;
 
void solve(int tc){
    int n,q; cin >> n >> q;
    vector<int>a(n),b(n);
    for(int i=0;i<n;i++)cin >> a[i];
    for(int i=0;i<n;i++)cin >> b[i];
    int sum = 0;
    for(int i=0;i<n;i++)sum += min(a[i],b[i]);
    while(q--){
        char c; cin >> c;
        int idx , val; cin >> idx >> val;
        idx--;
        sum -= min(a[idx],b[idx]);
        if(c=='A')a[idx] = val;
        else b[idx]= val;
        sum += min(a[idx],b[idx]);
        cout << sum << endl;
    }

}
int32_t main(){

    Fast

    int t=1;

    // cin >> t;

    for(int tc=1;tc<=t;tc++){

        solve(tc);
    }
    return 0;
}

Submission Info

Submission Time
Task C - Sum of Min Query
User H_R_K
Language C++ 20 (gcc 12.2)
Score 300
Code Size 1116 Byte
Status AC
Exec Time 76 ms
Memory 6804 KiB

Compile Error

Main.cpp: In function ‘void solve(long long int)’:
Main.cpp:18:16: warning: unused parameter ‘tc’ [-Wunused-parameter]
   18 | void solve(int tc){
      |                ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 23
Set Name Test Cases
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
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3532 KiB
00_sample_01.txt AC 1 ms 3472 KiB
00_sample_02.txt AC 1 ms 3420 KiB
01_random_00.txt AC 1 ms 3412 KiB
01_random_01.txt AC 75 ms 6804 KiB
01_random_02.txt AC 69 ms 6160 KiB
01_random_03.txt AC 33 ms 4660 KiB
01_random_04.txt AC 72 ms 6240 KiB
01_random_05.txt AC 30 ms 5160 KiB
01_random_06.txt AC 52 ms 4936 KiB
01_random_07.txt AC 17 ms 4724 KiB
01_random_08.txt AC 75 ms 6504 KiB
01_random_09.txt AC 68 ms 6372 KiB
01_random_10.txt AC 73 ms 6544 KiB
01_random_11.txt AC 65 ms 6248 KiB
01_random_12.txt AC 74 ms 6512 KiB
01_random_13.txt AC 74 ms 6608 KiB
01_random_14.txt AC 74 ms 6548 KiB
01_random_15.txt AC 76 ms 6504 KiB
01_random_16.txt AC 75 ms 6544 KiB
01_random_17.txt AC 75 ms 6580 KiB
01_random_18.txt AC 74 ms 6316 KiB
01_random_19.txt AC 76 ms 6544 KiB