QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#361221 | #8276. Code Congestion | paoxiaomo | WA | 1ms | 3884kb | C++17 | 4.6kb | 2024-03-22 23:12:26 | 2024-03-22 23:12:27 |
Judging History
answer
//#pragma GCC optimize(2,"Ofast")
//#pragma GCC optimize(3,"inline")
#include<bits/stdc++.h>
using namespace std;
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;
//--------------------------Abbreviations--------------------------//
#define x1 __________________
#define y1 ___________________
#define x2 ____________________
#define y2 _____________________
#define endl '\n'
#define uint unsigned int
#define int long long
using ll = long long;
using ld = long double;
using ull = unsigned long long;
//using lll = __int128;
using vi = vector<int>;
template <class T> using vc = vector<T>;
template <class T> using vvc = vector<vc<T>>;
template <class T> using vvvc = vector<vvc<T>>;
using ai2 = array<int, 2>;using ai3 = array<int, 3>;
using ai4 = array<int, 4>;using ai5 = array<int, 5>;
struct custom_hash {
static uint64_t splitmix64(uint64_t x) {
x += 0x9e3779b97f4a7c15;
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
return x ^ (x >> 31);
}
size_t operator()(uint64_t x) const {
static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
return splitmix64(x + FIXED_RANDOM);
}
};
template<class Key> using uset = unordered_set<Key, custom_hash>;
template<class Key, class Value> using umap = unordered_map<Key, Value, custom_hash>;
//--------------------------Function--------------------------//
#define sqrt(x) sqrtl(x)
#define log2(x) (63 - __builtin_clzll(x))
#define Ones(x) __builtin_popcountll(x)
//#define max(a, b) ((a) > (b) ? (a) : (b))
//#define min(a, b) ((a) < (b) ? (a) : (b))
ld getld() { string x;cin >> x;return stold(x); }
template<typename T> inline bool chkmax(T& a, T b) { if (a >= b) return 0;a = b;return 1; }
template<typename T> inline bool chkmin(T& a, T b) { if (a <= b) return 0;a = b;return 1; }
//--------------------------Debug--------------------------//
#ifdef LOCAL
#define debug_(x) cerr << #x << " = " << (x) << ' '
#define debug(x) cerr << #x << " = " << (x) << '\n'
#define debugsq(x) cerr << #x << ": ["; for (auto i : x) cerr << i << ' '; cerr << "]\n";
#define debugmp(x) cerr << #x << ": [ "; for (auto [i, j] : x) cerr << '[' << i << "," << j << "] "; cerr << "]\n";
#define debugs(x...) do{cerr << #x << " : "; ERR(x);} while (0)
void ERR() { cerr << endl; } template <class T, class... Ts> void ERR(T arg, Ts ...args) { cerr << arg << ", ";ERR(args...); }
#else
#define debug(...) 'm'
#define debug_(...) 'r'
#define debugsq(...) 's'
#define debugmp(...) 'u'
#define debugs(...) 'n'
#define ERR() 's'
#endif
//--------------------------Constant--------------------------//
const ll inf = 1e18;
const int N = 2e5 + 10;
const int MOD = 998244353;//998244353
//const __int128 ONE = 1;
//--------------------------Other--------------------------//
int mx[]{ 0,-1,0,1 };
int my[]{ 1,0,-1,0 };
#define YES cout << "YES" << '\n'
#define NO cout << "NO" << '\n'
#define quit cout << "quit" << '\n'; return
template <class... Args> void myin(Args&... args) { ((cin >> args), ...); }
template <class... Args> void myout(const Args&... args) { ((cout << args), ...); }
//ofstream mcout("C:/Users/Mrsuns/Desktop/out.txt");
//ofstream mcout("C:/Users/Mrsuns/Desktop/out.txt");
//--------------------------END--------------------------//
int pw[N];
void PreWork(int n) {
pw[0] = 1;
for (int i = 1;i <= n;i++) pw[i] = pw[i - 1] * 2 % MOD;
}
void Solve(int TIME) {
int n, T;
cin >> n >> T;
vector<int> a(n + 1);
for (int i = 1; i <= n; i++) cin >> a[i];
vector<int> t(n + 1);
for (int i = 1; i <= n; i++) cin >> t[i];
vector<int> f(T + 1);f[0] = 1;
vector<int> g(T + 1);g[0] = 1;
int res = 0;
for (int i = 1;i <= n;i++) {
for (int j = T;j >= t[i];j--) {
(f[j] += f[j - t[i]]) %= MOD;
res = (res + f[j - t[i]] * pw[n - i] % MOD * a[i] % MOD) % MOD;
}
}
//debug(res);
vector<int> pre(n + 1);
for (int i = 1; i <= n; i++) pre[i] = pre[i - 1] + t[i];
for (int i = n; i >= 1; i--) {
for (int j = 0; j <= T - pre[i]; j++)
res = (res + g[j] * a[i] * pw[i - 1] % MOD) % MOD;
for (int j = T; j >= t[i]; j--) {
(g[j] += g[j - t[i]]) %= MOD;
}
}
cout << res << endl;
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cout << fixed << setprecision(15);
PreWork(1000);
int T = 1;
//cin >> T;
int TIME = 0;
while (T--) {
Solve(++TIME);
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3620kb
input:
3 3 2 3 4 1 2 2
output:
40
result:
ok 1 number(s): "40"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3884kb
input:
13 96 56231 258305 150103 164646 232643 37457 239584 192517 167805 215281 159832 98020 141006 54 1 38 1 4 1 4 11 1 4 8 22 1
output:
745634757
result:
ok 1 number(s): "745634757"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
14 86 205026 38691 58462 59767 205360 152715 7879 105238 33507 280429 54906 248241 102327 202931 1 49 1 1 5 12 1 5 9 18 1 1 3 32
output:
310231569
result:
ok 1 number(s): "310231569"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3652kb
input:
14 85 82111 267744 229782 32542 260127 152775 1364 293699 23965 242667 264864 219673 189482 12945 1 5 1 1 2 1 38 14 1 3 4 1 21 53
output:
745175834
result:
ok 1 number(s): "745175834"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
15 94 119505 80865 95965 30047 68261 120903 113180 192738 220899 279742 32609 275645 38640 213859 282516 1 1 8 15 1 3 1 38 6 1 23 57 1 5 79
output:
970187257
result:
ok 1 number(s): "970187257"
Test #6:
score: 0
Accepted
time: 1ms
memory: 3624kb
input:
200 91 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...
output:
602403195
result:
ok 1 number(s): "602403195"
Test #7:
score: -100
Wrong Answer
time: 1ms
memory: 3688kb
input:
198 87 276373 259622 211541 127475 41483 45243 254828 92569 120672 280027 180073 248960 25052 110553 136460 102137 166179 165627 29260 33966 121236 34304 67399 250912 104260 114026 261774 159285 218100 110269 112808 224799 170009 150816 34232 290942 52872 176861 177679 36123 92008 39070 265659 25497...
output:
403575201
result:
wrong answer 1st numbers differ - expected: '605480487', found: '403575201'