QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#463601 | #7304. Coins 2 | hos_lyric | TL | 0ms | 3956kb | C++14 | 2.1kb | 2024-07-05 05:30:42 | 2024-07-05 05:30:43 |
Judging History
answer
#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using Int = long long;
template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }
#define COLOR(s) ("\x1b[" s "m")
int N;
vector<Int> A;
vector<Int> suf;
vector<Int> ans;
void dfs(int i, int k, Int s) {
if (i > N) {
return;
}
// last non-full here
if (k < i) {
for (Int x = 0; x < A[i]; ++x) {
ans.push_back(s + x * i + suf[i + 1]);
}
}
for (Int x = 0; x <= A[i] && k + x < N; ++x) {
dfs(i + 1, k + x, s + x * i);
}
}
int main() {
for (; ~scanf("%d", &N); ) {
A.assign(N + 1, 0);
for (int i = 1; i <= N; ++i) {
scanf("%lld", &A[i]);
}
suf.assign(N + 2, 0);
for (int i = N; i >= 1; --i) {
suf[i] = A[i] * i + suf[i + 1];
}
ans = {suf[1]};
dfs(1, 0, 0);
sort(ans.begin(), ans.end());
ans.erase(unique(ans.begin(), ans.end()), ans.end());
// cerr<<"ans = "<<ans<<endl;
printf("%d\n", (int)ans.size());
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3956kb
input:
3 0 1 2 3 0 2 3
output:
6 12
result:
ok 2 number(s): "6 12"
Test #2:
score: -100
Time Limit Exceeded
input:
1 0 15 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000