Submission #70767030


Source Code Expand

#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include <stdlib.h>
#include<string>
#include<math.h>
#include<sstream>
#include<set>
#include<math.h>
#include <algorithm>
#include<map>
#include <numeric>
#include <sstream>
#include <iomanip>
#include<tuple>
#include <bitset>
#include <queue>
#include <iomanip>
#include <stack>
#include<time.h>
#include <unordered_set>
#include <random>
using namespace::std;
#define RANDMAX  100000
#define ll long long 
#define lint long long int
#define ldouble long double
#define ALL(a)  (a).begin(),(a).end()
using ve = vector<lint>;

vector<vector<int>> map2;
//
using Gra = vector<vector<lint>>;
using sve = vector<string>;
//  


//cout << std::fixed << std::setprecision(15)<< ans;//小数点
//

// 
//<stack>//上から
// box.push()
// box.pop()
// box.top()
// 
// <queue>下から
// box.push()
// box.front()
// box.pop()
// 
// <set>
// ite=g2.lower_bound(r) set二部探索
// distance(ls.begin(), ite);探索した後の引数
// advance() は極力使わないこと!! ***************************************
// g2.count() set()内の個数
// lower_bound(a.begin(),a.end(),a[i])
// box.size()
// 
// <vector>
// vector<int>
// lower_bound(a.begin(),a.end(),a[i])
// vector<vector<lint>> v(2, vector<lint>(3)) -> v.at(1).at(2);
// next_permutation(aaa.begin(), aaa.end()) ベクターの組み合わせ
//
//<2分探索 ~手動実装偏~>
// int binary_search(int key) {
//    int left = 0, right = (int)a.size() - 1; // 配列 a の左端と右端
//    while (right >= left) {
//        int mid = left + (right - left) / 2; // 区間の真ん中
//        if (a[mid] == key) return mid;
//        else if (a[mid] > key) right = mid - 1;
//        else if (a[mid] < key) left = mid + 1;
//    }
//    return -1;
// }
// 
// <bit全探索>
// bitset<60> bs(n);
//
//鶏をswapするときは箱の番号を変える






/*	par=time_check(nh, nm);
    nh = par.first; nm = par.second;*/
pair<lint, lint> time_check(int h, int m) {
    while (m >= 60) {
        h += 1;
        m -= 60;
    }
    while (m < 0) {
        h -= 1;
        m += 60;
    }
    return make_pair(h, m);
}


std::random_device seed_gen;
uint32_t get_rand() {
    // 乱数生成器(引数にシードを指定可能)
    static std::mt19937 mt32(seed_gen());

    // [0, (2^32)-1] の一様分布整数を生成
    return mt32();
}

class ansd {
public:
    int p;
    int x;
    int y;
};

class zahyo {
public:
    int x;
    int y;
};


int main() {
    int x, n;
    cin >> x >> n;
    vector<int> w(n);
    for (int i = 0; i < n; i++) {
        cin >> w[i];
    }
    set<int>box;
    int a = x,p;
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        cin >> p;
        p--;
        auto ite = box.find(p);
        if (ite == box.end()) {
            a += w[p];
            box.insert(p);
        }
        else {
            a -= w[p];
            box.erase(p);
        }
        cout << a << endl;;
    }
}

Submission Info

Submission Time
Task B - Robot Weight
User tbbt95
Language C++23 (GCC 15.2.0)
Score 200
Code Size 3154 Byte
Status AC
Exec Time 1 ms
Memory 3628 KiB

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 1 ms 3396 KiB
00_sample_01.txt AC 1 ms 3496 KiB
01_random_02.txt AC 1 ms 3436 KiB
01_random_03.txt AC 1 ms 3524 KiB
01_random_04.txt AC 1 ms 3496 KiB
01_random_05.txt AC 1 ms 3592 KiB
01_random_06.txt AC 1 ms 3592 KiB
01_random_07.txt AC 1 ms 3592 KiB
01_random_08.txt AC 1 ms 3584 KiB
01_random_09.txt AC 1 ms 3564 KiB
01_random_10.txt AC 1 ms 3484 KiB
01_random_11.txt AC 1 ms 3488 KiB
01_random_12.txt AC 1 ms 3508 KiB
01_random_13.txt AC 1 ms 3564 KiB
01_random_14.txt AC 1 ms 3484 KiB
01_random_15.txt AC 1 ms 3496 KiB
01_random_16.txt AC 1 ms 3628 KiB