답안 #545166

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
545166 2022-04-03T18:01:14 Z MilosMilutinovic Collecting Stamps 3 (JOI20_ho_t3) C++14
15 / 100
165 ms 65292 KB
#include<bits/stdc++.h>

#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template<typename T> bool chkmin(T&x,T y){return x>y?x=y,1:0;}
template<typename T> bool chkmax(T&x,T y){return x<y?x=y,1:0;}

int n,k,a[205],t[205],dp[205][205][205][2];

int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++) scanf("%d",&t[i]);
	for(int i=0;i<=n;i++) for(int l=0;l<=n;l++) for(int r=0;r<=n;r++) dp[l][r][i][0]=dp[l][r][i][1]=1e9;
	dp[0][0][0][0]=dp[0][0][0][1]=0;
	for(int i=0;i<n;i++) for(int l=0;l<=n;l++) for(int r=0;r<=n;r++) if(l+r<n) for(int st=0;st<2;st++) {
		{
			//left
			int nt=dp[i][l][r][st]+(st==0?a[l+1]-a[l]:k-a[n+1-r]+a[l+1]);
			chkmin(dp[i+(nt<=t[l+1])][l+1][r][0],nt);
		}
		{
			//right
			int nt=dp[i][l][r][st]+(st==0?a[l]+k-a[n-r]:(a[n+1-r]-a[n-r]+k)%k);
			chkmin(dp[i+(nt<=t[n-r])][l][r+1][1],nt);
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++) for(int l=0;l<=n;l++) for(int r=0;r<=n;r++) if(dp[i][l][r][0]!=1e9||dp[i][l][r][1]!=1e9) ans=i;
	printf("%d",ans);
	return 0;
}

Compilation message

ho_t3.cpp: In function 'int main()':
ho_t3.cpp:21:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |  scanf("%d%d",&n,&k);
      |  ~~~~~^~~~~~~~~~~~~~
ho_t3.cpp:22:29: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |  for(int i=1;i<=n;i++) scanf("%d",&a[i]);
      |                        ~~~~~^~~~~~~~~~~~
ho_t3.cpp:23:29: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |  for(int i=1;i<=n;i++) scanf("%d",&t[i]);
      |                        ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 436 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 436 KB Output is correct
9 Correct 1 ms 596 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 308 KB Output is correct
12 Correct 1 ms 596 KB Output is correct
13 Correct 1 ms 596 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 596 KB Output is correct
17 Correct 1 ms 596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 436 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 436 KB Output is correct
9 Correct 1 ms 596 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 308 KB Output is correct
12 Correct 1 ms 596 KB Output is correct
13 Correct 1 ms 596 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 596 KB Output is correct
17 Correct 1 ms 596 KB Output is correct
18 Incorrect 1 ms 688 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 436 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 436 KB Output is correct
9 Correct 1 ms 596 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 308 KB Output is correct
12 Correct 1 ms 596 KB Output is correct
13 Correct 1 ms 596 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 596 KB Output is correct
17 Correct 1 ms 596 KB Output is correct
18 Correct 134 ms 52896 KB Output is correct
19 Correct 60 ms 32140 KB Output is correct
20 Correct 26 ms 17296 KB Output is correct
21 Correct 52 ms 30392 KB Output is correct
22 Correct 79 ms 39536 KB Output is correct
23 Correct 22 ms 14740 KB Output is correct
24 Correct 18 ms 11604 KB Output is correct
25 Correct 23 ms 14472 KB Output is correct
26 Correct 5 ms 5716 KB Output is correct
27 Correct 26 ms 15060 KB Output is correct
28 Correct 14 ms 10848 KB Output is correct
29 Correct 21 ms 15316 KB Output is correct
30 Correct 14 ms 12192 KB Output is correct
31 Correct 21 ms 14420 KB Output is correct
32 Correct 8 ms 7636 KB Output is correct
33 Correct 22 ms 14500 KB Output is correct
34 Correct 4 ms 5332 KB Output is correct
35 Correct 17 ms 14144 KB Output is correct
36 Correct 9 ms 6868 KB Output is correct
37 Correct 22 ms 15020 KB Output is correct
38 Correct 10 ms 8404 KB Output is correct
39 Correct 25 ms 15704 KB Output is correct
40 Correct 10 ms 9300 KB Output is correct
41 Correct 165 ms 65292 KB Output is correct
42 Correct 77 ms 44052 KB Output is correct
43 Correct 158 ms 65180 KB Output is correct
44 Correct 93 ms 43508 KB Output is correct
45 Correct 154 ms 65248 KB Output is correct
46 Correct 77 ms 44120 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 436 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 436 KB Output is correct
9 Correct 1 ms 596 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 308 KB Output is correct
12 Correct 1 ms 596 KB Output is correct
13 Correct 1 ms 596 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 596 KB Output is correct
17 Correct 1 ms 596 KB Output is correct
18 Incorrect 1 ms 688 KB Output isn't correct
19 Halted 0 ms 0 KB -