QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#225593 | #5177. 摩斯电码 2.0 | hos_lyric# | 40 | 9ms | 6104kb | C++14 | 2.4kb | 2023-10-24 20:28:04 | 2024-07-04 02:21:29 |
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")
constexpr Int INF = 1001001001001001001LL;
int N;
Int M;
vector<Int> V, A;
namespace brute {
Int dp[1010][1010];
bool check(int want) {
for (int i = 0; i <= N; ++i) {
fill(dp[i], dp[i] + (M - want + 1), INF);
}
dp[1][0] = 0;
for (int i = 1; i < N; ++i) {
for (int x = 0; x <= M - want; ++x) if (dp[i][x] < INF) {
for (int y = 0; x + y <= M - want; ++y) {
// v[i] / (y + 1) <= V[0] / want
const Int w = V[0] * (y + 1) / want - (V[i] + dp[i][x]);
if (w >= 0) {
chmin(dp[i + 1][x + y], max(A[i] - w, 0LL));
}
}
}
}
return (dp[N][M - want] < INF);
}
Int run() {
cerr<<"[brute::run]"<<endl;
int lo = 0, hi = M + 1;
for (; lo + 1 < hi; ) {
const int mid = (lo + hi) / 2;
(check(mid) ? lo : hi) = mid;
}
return lo;
}
} // brute
int main() {
for (; ~scanf("%d%lld", &N, &M); ) {
V.resize(N); for (int i = 0; i < N; ++i) scanf("%lld", &V[i]);
A.resize(N); for (int i = 0; i < N; ++i) scanf("%lld", &A[i]);
V[0] += A[0] + A[N - 1];
A[0] = A[N - 1] = 0;
const Int ans = brute::run();
printf("%lld\n", ans);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 10
Accepted
Test #1:
score: 10
Accepted
time: 0ms
memory: 3892kb
input:
5 5 2 5 5 4 3 2 4 4 5 5
output:
2
result:
ok single line: '2'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3968kb
input:
5 5 2 2 1 3 2 1 4 1 5 1
output:
1
result:
ok single line: '1'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3972kb
input:
5 5 4 5 1 4 3 4 5 1 2 5
output:
3
result:
ok single line: '3'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3972kb
input:
5 4 5 2 5 1 1 0 3 0 0 0
output:
2
result:
ok single line: '2'
Subtask #2:
score: 10
Accepted
Test #5:
score: 10
Accepted
time: 0ms
memory: 3888kb
input:
5 38 170 62 7 129 93 39 98 2 178 110
output:
15
result:
ok single line: '15'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3936kb
input:
9 75 175 240 5 139 127 216 66 128 121 94 204 150 150 50 66 26 225 142
output:
14
result:
ok single line: '14'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3900kb
input:
4 81 99 122 93 175 210 91 93 20
output:
30
result:
ok single line: '30'
Test #8:
score: 0
Accepted
time: 0ms
memory: 4092kb
input:
50 4 249 124 249 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 0 125 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
output:
2
result:
ok single line: '2'
Subtask #3:
score: 20
Accepted
Test #9:
score: 20
Accepted
time: 9ms
memory: 4260kb
input:
50 340 145945353 943649879 103681368 412537460 249168929 368424447 732376003 185334999 144319344 511521494 159409847 131972188 193314434 725004712 439570846 364294834 362411427 314220847 829136416 305293003 505373341 638710304 851245152 521859350 644327541 974583375 738591681 147795709 922157319 421...
output:
1
result:
ok single line: '1'
Test #10:
score: 0
Accepted
time: 1ms
memory: 4016kb
input:
50 4 812930736 95702098 665441738 221300735 907249385 493535187 564488639 395538786 904638787 889168971 900357003 21636011 764504998 243769369 89695414 656445453 745884937 656421159 296885639 206987195 368396912 54679316 346974906 192974419 56304682 420269636 396600899 473826419 708845531 57105109 5...
output:
2
result:
ok single line: '2'
Test #11:
score: 0
Accepted
time: 5ms
memory: 6104kb
input:
50 242 21994377 883494624 811211287 2014707 690537081 642841499 847215492 156177058 39805037 586706497 747465489 685773253 531808559 229539707 496349943 951616271 871232872 203160652 315507929 814504770 613932493 843612050 706827895 664552255 385267680 711345437 661256346 598502814 135899412 8864698...
output:
3
result:
ok single line: '3'
Test #12:
score: 0
Accepted
time: 0ms
memory: 3956kb
input:
50 4 999999999 499999999 999999999 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 0 500000000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
output:
2
result:
ok single line: '2'
Subtask #4:
score: 0
Time Limit Exceeded
Test #13:
score: 0
Time Limit Exceeded
input:
1000 1000 1000000000 732930495 57470406 998674942 980507254 200197125 826994891 726235561 146440304 908089621 108786784 22006340 629816450 656110319 505896602 620885446 857656443 30603288 902307001 946990065 915078227 237356805 675986931 241912445 489230924 199892606 129509547 544771174 171477200 39...
output:
result:
Subtask #5:
score: 0
Runtime Error
Test #17:
score: 0
Runtime Error
input:
10000 1000000000 1000000000 9322 8270 4220 4967 6470 2768 7780 590 1436 4219 7804 8549 8916 9250 1420 5911 2115 7098 9942 4217 7430 5121 4217 395 1363 1098 3314 2058 6689 3270 6734 6663 2769 7773 5406 5705 1208 4409 6282 5593 7665 1334 6208 1138 6856 4597 2152 3666 5645 6841 1182 8469 1768 9165 4521...
output:
result:
Subtask #6:
score: 0
Runtime Error
Test #21:
score: 0
Runtime Error
input:
100000 1000000000 1000000000 34788 73380 66152 92356 82130 69036 96709 88944 26043 93630 93922 79818 18546 43338 40621 46994 77235 61925 24567 63929 22345 8049 40400 68808 79834 10769 68961 415 75455 73445 65121 66981 39924 45321 66260 43977 81382 98200 6894 11936 10781 29304 45584 12022 26163 73225...