Submission #967705

#TimeUsernameProblemLanguageResultExecution timeMemory
967705vjudge1Ice Hockey World Championship (CEOI15_bobek)C++17
0 / 100
2 ms348 KiB
#include <iostream> #include <vector> using namespace std; long long countSubsequences(const vector<int>& arr, int n, long long k) { long long result = 0; // Iterate through all possible subsequences for (int i = 0; i < n; ++i) { for (int j = i; j < n; ++j) { for (int l = j; l < n; ++l) { for (int m = l; m < n; ++m) { long long sum = 0; // Calculate the sum of the current subsequence for (int idx = i; idx <= m; ++idx) { sum += arr[idx]; } // Check if the sum is less than or equal to k if (sum <= k) { ++result; } } } } } return result; } int main() { int n; long long k; cin >> n; vector<int> arr(n); for (int i = 0; i < n; ++i) cin >> arr[i]; cin >> k; long long result = countSubsequences(arr, n, k); cout << result << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...