Submission #545168

# Submission time Handle Problem Language Result Execution time Memory
545168 2022-04-03T18:02:02 Z MilosMilutinovic Collecting Stamps 3 (JOI20_ho_t3) C++14
Compilation error
0 ms 0 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];
ll 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]=1e18;
	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]!=1e18|dp[i][l][r][1]!=1e18) ans=i;
	printf("%d",ans);
	return 0;
}

Compilation message

ho_t3.cpp: In function 'int main()':
ho_t3.cpp:31:43: error: no matching function for call to 'chkmin(ll&, int&)'
   31 |    chkmin(dp[i+(nt<=t[l+1])][l+1][r][0],nt);
      |                                           ^
ho_t3.cpp:15:27: note: candidate: 'template<class T> bool chkmin(T&, T)'
   15 | template<typename T> bool chkmin(T&x,T y){return x>y?x=y,1:0;}
      |                           ^~~~~~
ho_t3.cpp:15:27: note:   template argument deduction/substitution failed:
ho_t3.cpp:31:43: note:   deduced conflicting types for parameter 'T' ('long long int' and 'int')
   31 |    chkmin(dp[i+(nt<=t[l+1])][l+1][r][0],nt);
      |                                           ^
ho_t3.cpp:36:43: error: no matching function for call to 'chkmin(ll&, int&)'
   36 |    chkmin(dp[i+(nt<=t[n-r])][l][r+1][1],nt);
      |                                           ^
ho_t3.cpp:15:27: note: candidate: 'template<class T> bool chkmin(T&, T)'
   15 | template<typename T> bool chkmin(T&x,T y){return x>y?x=y,1:0;}
      |                           ^~~~~~
ho_t3.cpp:15:27: note:   template argument deduction/substitution failed:
ho_t3.cpp:36:43: note:   deduced conflicting types for parameter 'T' ('long long int' and 'int')
   36 |    chkmin(dp[i+(nt<=t[n-r])][l][r+1][1],nt);
      |                                           ^
ho_t3.cpp:40:85: warning: suggest parentheses around comparison in operand of '|' [-Wparentheses]
   40 |  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]!=1e18|dp[i][l][r][1]!=1e18) ans=i;
      |                                                                       ~~~~~~~~~~~~~~^~~~~~
ho_t3.cpp:22:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |  scanf("%d%d",&n,&k);
      |  ~~~~~^~~~~~~~~~~~~~
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",&a[i]);
      |                        ~~~~~^~~~~~~~~~~~
ho_t3.cpp:24:29: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |  for(int i=1;i<=n;i++) scanf("%d",&t[i]);
      |                        ~~~~~^~~~~~~~~~~~