Submission #70775899


Source Code Expand

#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007
#define mm(arr) memset(arr, 0, sizeof(arr))
#define F first
#define S second

int32_t main(){
    FAST
    int x; cin >> x;
    int n; cin >> n;
    int w[n];
    for(int i = 0; i < n; i++){
        cin >> w[i];
    }
    bool has[n];
    mm(has);
    int q; cin >> q;
    while(q--){
        int t; cin >> t;
        t--;
        if(has[t]){
            x -= w[t];
        }
        else{
            x += w[t];
        }
        has[t] = !has[t];
        cout << x << endl;
    }
    return 0;
}

Submission Info

Submission Time
Task B - Robot Weight
User Basilhijaz
Language C++23 (Clang 21.1.0)
Score 200
Code Size 905 Byte
Status AC
Exec Time 2 ms
Memory 3096 KiB

Compile Error

./Main.cpp:22:11: warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
   22 |     int w[n];
      |           ^
./Main.cpp:22:11: note: read of non-const variable 'n' is not allowed in a constant expression
./Main.cpp:21:9: note: declared here
   21 |     int n; cin >> n;
      |         ^
./Main.cpp:26:14: warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
   26 |     bool has[n];
      |              ^
./Main.cpp:26:14: note: read of non-const variable 'n' is not allowed in a constant expression
./Main.cpp:21:9: note: declared here
   21 |     int n; cin >> n;
      |         ^
2 warnings generated.

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 2
AC × 17
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt
All 00_sample_00.txt, 00_sample_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
Case Name Status Exec Time Memory
00_sample_00.txt AC 2 ms 3036 KiB
00_sample_01.txt AC 1 ms 2912 KiB
01_random_02.txt AC 1 ms 2948 KiB
01_random_03.txt AC 1 ms 3084 KiB
01_random_04.txt AC 1 ms 3096 KiB
01_random_05.txt AC 1 ms 3052 KiB
01_random_06.txt AC 1 ms 2880 KiB
01_random_07.txt AC 1 ms 3048 KiB
01_random_08.txt AC 1 ms 3088 KiB
01_random_09.txt AC 1 ms 2912 KiB
01_random_10.txt AC 1 ms 3052 KiB
01_random_11.txt AC 1 ms 3088 KiB
01_random_12.txt AC 1 ms 3096 KiB
01_random_13.txt AC 1 ms 3048 KiB
01_random_14.txt AC 1 ms 3016 KiB
01_random_15.txt AC 1 ms 3084 KiB
01_random_16.txt AC 1 ms 3088 KiB