Submission #886519

# Submission time Handle Problem Language Result Execution time Memory
886519 2023-12-12T09:23:08 Z vjudge1 Gym Badges (NOI22_gymbadges) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;

template<typename A, typename B>
string to_string(pair<A, B>);
string to_string(string S) {
  return '"' + S + '"';
}
string to_string(const char* c) {
  return to_string(string(c));
}
string to_string(bool b) {
  return (b ? "true" : "false");
}
template<size_t T>
string to_string(bitset<T> bs) {
  return bs.to_string();
}
string to_string(vector<bool> v) {
  string res = "{";
  for (int i = 0; i < int(v.size()); ++i) {
    if (int(res.size()) > 1) {
      res += ", ";
    }
    res += to_string(v[i]);
  }
  return res + "}";
}
template<typename T>
string to_string(T v) {
  string res = "{";
  for (auto e : v) {
    if (int(res.size()) > 1) {
      res += ", ";
    }
    res += to_string(e);
  }
  return res + "}";
}
template<typename T>
string to_string(priority_queue<T> pq) {
  vector<T> a;
  while (!pq.empty()) {
    a.push_back(pq.top());
    pq.pop();
  }
  return to_string(a);
}
template<typename A, typename B>
string to_string(pair<A, B> p) {
  return '(' + to_string(p.first) + ", " + to_string(p.second) + ')';
}
void debug_out() {
  cerr << endl;
}
template<typename H, typename... T>
void debug_out(H head, T... tail) {
  cerr << "  " << to_string(head);
  debug_out(tail...);
}
#ifdef DEBUG 
  #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__) 
#else 
  #define debug(...) void(37)
#endif

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> X(N), L(N);
  for (int i = 0; i < N; ++i) {
    cin >> X[i];
  }
  for (int i = 0; i < N; ++i) {
    cin >> L[i];
  }
  vector<int> S(N);
  for (int i = 0; i < N; ++i) {
    S[i] = X[i] + L[i];
  }
  vector<int> ord(N);
  iota(ord.begin(), ord.end(), 0);
  sort(ord.begin(), ord.end(), [&](int x, int y) {
    return S[x] < S[y];
  });
  priority_queue<int> pq;
  long long last = 0;
  for (auto i : ord)
    pq.push(X[i]);
    last += X[i];
    if (last > S[i]) {
      last -= pq.top();
      pq.pop();
    }
  }
  cout << int(pq.size()) << '\n';
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:91:3: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   91 |   for (auto i : ord)
      |   ^~~
Main.cpp:93:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   93 |     last += X[i];
      |     ^~~~
Main.cpp:93:15: error: 'i' was not declared in this scope
   93 |     last += X[i];
      |               ^
Main.cpp: At global scope:
Main.cpp:99:3: error: 'cout' does not name a type
   99 |   cout << int(pq.size()) << '\n';
      |   ^~~~
Main.cpp:100:1: error: expected declaration before '}' token
  100 | }
      | ^