We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Fraudulent Activity Notifications
Fraudulent Activity Notifications
Sort by
recency
|
1180 Discussions
|
Please Login in order to post a comment
include
using namespace std;
int test(const vector &a, int n, int d) { int res = 0; vectorb(a.begin(), a.begin() + d); sort(b.begin(), b.end()); for(int i = d; i < n; i++) { int sum = 0; if(d % 2 == 1) { sum = 2 * b[d / 2]; } else { sum = b[d / 2] + b[d / 2 - 1]; } if(a[i] >= sum) { res++; } b.erase(lower_bound(b.begin(), b.end(), a[i - d])); b.insert(lower_bound(b.begin(), b.end(), a[i]), a[i]); } return res; }
int main() { int n, d; cin >> n >> d; vector a(n); for(int i = 0; i < n; i++) { cin >> a[i]; } cout << test(a, n, d) << endl; return 0; }
Python3 using bisect library
C#
i did this solution: but only 5/8. what is wrong?
public static int activityNotifications(List expenditure, int d) { int counter=0; int sum=0;