이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define GOOD_LUCK ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define int long long
#define itn int
#define Int int
#define INF -1000000
#define MOD 1000000007
#define endl "\n"
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
using namespace std;
int temp;
signed main() {
GOOD_LUCK
int t;
t = 1;
// cin >> t;
while (t--) {
int n, m, s=1, cnt=0, k=0;
cin >> n >> m;
vector <int> v;
for (int i=0; i < n; i++) {
cin >> temp;
if (temp < m) {
v.push_back(temp);
k+=temp;
}
if (temp == m) s++;
}
if (k <= m) {
cout << (1 << v.size()) + s;
break;
}
n = v.size();
// sort(v.begin(), v.end());
int p[n];
for (int i=0; i < n; i++) {
if (i ==0) p[i] = v[i];
else p[i] = p[i-1] + v[i];
}
for (int i=0; i < n; i++) {
for (int j=i; j < n; j++) {
if (p[j] - p[i-1] <= m) cnt++;
}
}
cout << cnt + s;
}
return 0;
}
// Problem B
// by Ekber_Ekber
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |