Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <set>
- using namespace std;
- int main() {
- int n;
- cin >> n;
- int r[n], c[n], s[n];
- char a;
- for (int j = 0; j < n; j++) {
- cin >> a;
- s[j] = a - '0';
- }
- for (int j = 0; j < n; j++) {
- cin >> r[j];
- }
- for (int j = 0; j < n; j++) {
- cin >> c[j];
- }
- long long sm = 0;
- set <int> b;
- for (int j = 0; j < n; j++) {
- //cout << s[j] << '\n';
- if ((s[j] + b.size()) % 2) {
- cout << j + 1 << '\n';
- b.insert(r[j] - 1);
- sm += c[j];
- }
- while (b.size() && *b.begin() == j) {
- b.erase(b.begin());
- }
- }
- cout << sm;
- }
Add Comment
Please, Sign In to add comment