QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#340483 | #4398. Luxury cruise ship | crsfaa# | AC ✓ | 3ms | 11504kb | C++14 | 724b | 2024-02-29 09:03:27 | 2024-02-29 09:03:28 |
Judging History
answer
#include<bits/stdc++.h>
#define Yukinoshita namespace
#define Yukino std
#define int long long
using Yukinoshita Yukino;
int read()
{
int s=0,w=1;
char ch=getchar();
while(ch<'0'||ch>'9') w=ch=='-'?-1:1,ch=getchar();
while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
return s*w;
}
int dp[1000005];
signed main()
{
memset(dp,127,sizeof(dp));
//365000
int T=read(),i;
dp[0]=0;
for(i=1;i<=1e6;i++)
{
if(i>=7) dp[i]=min(dp[i],dp[i-7]+1);
if(i>=31) dp[i]=min(dp[i],dp[i-31]+1);
if(i>=365) dp[i]=min(dp[i],dp[i-365]+1);
}
while(T--)
{
int n=read(),i,j,mn=2e18;
for(i=n%365,j=0;i<=n&&j<1000;j++,i+=365)
mn=min(mn,dp[i]+(n-i)/365);
printf("%lld\n",mn>1e18?-1:mn);
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 3ms
memory: 11504kb
input:
1000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101...
output:
-1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 -1 -1 2 -1 -1 -1 -1 -1 -1 3 -1 -1 -1 -1 -1 -1 4 -1 -1 1 -1 -1 -1 5 -1 -1 2 -1 -1 -1 6 -1 -1 3 -1 -1 -1 7 -1 -1 4 -1 -1 -1 8 -1 -1 5 -1 -1 2 9 -1 -1 6 -1 -1 3 10 -1 -1 7 -1 -1 4 11 -1 -1 8 -1 -1 5 12 -1 -1 9 -1 -1 6 13 -1 3 10 -1 -1 7 14 -1 4 11 -1 -1 8 15 -1 5 12 -1 -...
result:
ok 1000 lines