armeer

Untitled

Aug 2nd, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. #include <iostream>
  2. #include <set>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. int n;
  8. cin >> n;
  9. int r[n], c[n], s[n];
  10. char a;
  11. for (int j = 0; j < n; j++) {
  12. cin >> a;
  13. s[j] = a - '0';
  14. }
  15. for (int j = 0; j < n; j++) {
  16. cin >> r[j];
  17. }
  18. for (int j = 0; j < n; j++) {
  19. cin >> c[j];
  20. }
  21. long long sm = 0;
  22. set <int> b;
  23. for (int j = 0; j < n; j++) {
  24. //cout << s[j] << '\n';
  25. if ((s[j] + b.size()) % 2) {
  26. cout << j + 1 << '\n';
  27. b.insert(r[j] - 1);
  28. sm += c[j];
  29. }
  30. while (b.size() && *b.begin() == j) {
  31. b.erase(b.begin());
  32. }
  33. }
  34. cout << sm;
  35. }
Add Comment
Please, Sign In to add comment