QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#560489 | #3588. Hamilton - The Musical | Yarema# | WA | 0ms | 3588kb | C++20 | 1.3kb | 2024-09-12 15:56:41 | 2024-09-12 15:56:41 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef double db;
const int LOG = 33;
const string days[7] = {"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"};
int f[LOG][5];
LL w[LOG][5];
void init()
{
FOR(i, 0, 5)
{
int t = 30;
while ((i + t) % 7 >= 5)
t++;
f[0][i] = (i + t) % 7;
w[0][i] = t;
}
FOR(j, 1, LOG)
{
FOR(i, 0, 5)
{
int k = f[j - 1][i];
f[j][i] = f[j - 1][k];
w[j][i] = w[j - 1][i] + w[j - 1][k];
}
}
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
init();
string s;
int n;
cin >> s >> n;
int today = find(days, days + 7, s) - days;
LL ans = 47;
while (n--)
{
int d;
cin >> d;
int v = ((today - d) % 7 + 7) % 7;
assert(0 <= v && v < 5);
LL sum = 0;
RFOR(i, LOG, 0)
{
if (sum + w[i][v] < d)
{
sum += w[i][v];
v = f[i][v];
}
}
if (sum < d)
{
sum += w[0][v];
}
ans = min(ans, sum - d);
}
cout << ans << "\n";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3588kb
input:
4 0 3 2 13 3 0 8 9 2 8 0 5 13 9 5 0
output:
47
result:
wrong answer 1st lines differ - expected: '16', found: '47'