답안 #201735

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
201735 2020-02-11T21:10:04 Z nikolapesic2802 Collecting Stamps 3 (JOI20_ho_t3) C++14
25 / 100
94 ms 63992 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define ll long long
#define pb push_back
#define sz(x) (int)(x).size()
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define D(x) cerr << #x << " is " << (x) << "\n";
#define ld long double

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>; ///find_by_order(),order_of_key()
template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1,T2>& a) { os << '{' << a.f << ", " << a.s << '}'; return os; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& a){os << '{';for(int i=0;i<sz(a);i++){if(i>0&&i<sz(a))os << ", ";os << a[i];}os<<'}';return os;}
template<class T> ostream& operator<<(ostream& os, const deque<T>& a){os << '{';for(int i=0;i<sz(a);i++){if(i>0&&i<sz(a))os << ", ";os << a[i];}os<<'}';return os;}
template<class T> ostream& operator<<(ostream& os, const set<T>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<class T> ostream& operator<<(ostream& os, const set<T,greater<T> >& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<class T> ostream& operator<<(ostream& os, const multiset<T>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<class T> ostream& operator<<(ostream& os, const multiset<T,greater<T> >& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<class T1,class T2> ostream& operator<<(ostream& os, const map<T1,T2>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}

const int N=201,oo=INT_MAX/2;
int dp[N][N][N][2],n,l,x[N+2],t[N];
int getDist(int a,int b){
	return min(abs(x[a]-x[b]),l-abs(x[a]-x[b]));
}
int main()
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	scanf("%i %i",&n,&l);
	for(int i=1;i<=n;i++)
		scanf("%i",&x[i]);
	for(int i=1;i<=n;i++)
		scanf("%i",&t[i]);
	for(int i=0;i<N;i++)for(int j=0;j<N;j++)for(int k=0;k<N;k++)dp[i][j][k][0]=dp[i][j][k][1]=oo;
	dp[0][0][0][0]=dp[0][0][0][1]=0;
	int sol=0;
	for(int i=0;i<N;i++){
		for(int j=0;j<=n-i;j++){
			for(int k=0;k<=n;k++){
				for(int o=0;o<2;o++){
					if(i+j>n||k>i+j||(i==0&&j==0)||(o==0&&i==0)||(o==1&&j==0))
						continue;
					if(o==0){ //left
						int time0=dp[i-1][j][k-1][0]+getDist(n-i+2,n-i+1),time1=dp[i-1][j][k-1][1]+getDist(j,n-i+1);  //Uzmi trenutni
						int time=min(time0,time1);
						if(time<=t[n-i+1])
							dp[i][j][k][o]=time;
						time0=dp[i-1][j][k][0]+getDist(n-i+2,n-i+1),time1=dp[i-1][j][k][1]+getDist(j-1,n-i+1);  //Nemoj uzeti trenuti
						time=min(time0,time1);
						dp[i][j][k][o]=min(dp[i][j][k][o],time);
					}
					else{ //right
						int time0=dp[i][j-1][k-1][0]+getDist(n-i+1,j),time1=dp[i][j-1][k-1][1]+getDist(j-1,j);  //Uzmi trenutni
						int time=min(time0,time1);
						if(time<=t[j])
							dp[i][j][k][o]=time;
						time0=dp[i][j-1][k][0]+getDist(n-i+1,j),time1=dp[i][j-1][k][1]+getDist(j-1,j);  //Nemoj uzeti trenuti
						time=min(time0,time1);
						dp[i][j][k][o]=min(dp[i][j][k][o],time);
					}
					if(dp[i][j][k][o]<oo)
						sol=max(sol,k);
				}
			}
		}
	}
	printf("%i\n",sol);
	return 0;
}

Compilation message

ho_t3.cpp: In function 'int main()':
ho_t3.cpp:40:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%i %i",&n,&l);
  ~~~~~^~~~~~~~~~~~~~~
ho_t3.cpp:42:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%i",&x[i]);
   ~~~~~^~~~~~~~~~~~
ho_t3.cpp:44:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%i",&t[i]);
   ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 63864 KB Output is correct
2 Correct 38 ms 63840 KB Output is correct
3 Correct 39 ms 63868 KB Output is correct
4 Correct 39 ms 63864 KB Output is correct
5 Correct 41 ms 63864 KB Output is correct
6 Correct 37 ms 63864 KB Output is correct
7 Correct 40 ms 63900 KB Output is correct
8 Correct 39 ms 63864 KB Output is correct
9 Correct 38 ms 63868 KB Output is correct
10 Correct 40 ms 63864 KB Output is correct
11 Correct 39 ms 63864 KB Output is correct
12 Correct 38 ms 63864 KB Output is correct
13 Correct 40 ms 63864 KB Output is correct
14 Correct 38 ms 63864 KB Output is correct
15 Correct 39 ms 63864 KB Output is correct
16 Correct 38 ms 63868 KB Output is correct
17 Correct 40 ms 63864 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 63864 KB Output is correct
2 Correct 38 ms 63840 KB Output is correct
3 Correct 39 ms 63868 KB Output is correct
4 Correct 39 ms 63864 KB Output is correct
5 Correct 41 ms 63864 KB Output is correct
6 Correct 37 ms 63864 KB Output is correct
7 Correct 40 ms 63900 KB Output is correct
8 Correct 39 ms 63864 KB Output is correct
9 Correct 38 ms 63868 KB Output is correct
10 Correct 40 ms 63864 KB Output is correct
11 Correct 39 ms 63864 KB Output is correct
12 Correct 38 ms 63864 KB Output is correct
13 Correct 40 ms 63864 KB Output is correct
14 Correct 38 ms 63864 KB Output is correct
15 Correct 39 ms 63864 KB Output is correct
16 Correct 38 ms 63868 KB Output is correct
17 Correct 40 ms 63864 KB Output is correct
18 Correct 37 ms 63864 KB Output is correct
19 Correct 39 ms 63892 KB Output is correct
20 Correct 40 ms 63868 KB Output is correct
21 Correct 38 ms 63992 KB Output is correct
22 Correct 38 ms 63864 KB Output is correct
23 Correct 42 ms 63864 KB Output is correct
24 Correct 39 ms 63864 KB Output is correct
25 Correct 39 ms 63864 KB Output is correct
26 Correct 38 ms 63864 KB Output is correct
27 Correct 41 ms 63864 KB Output is correct
28 Correct 38 ms 63868 KB Output is correct
29 Correct 40 ms 63864 KB Output is correct
30 Correct 38 ms 63864 KB Output is correct
31 Correct 38 ms 63864 KB Output is correct
32 Correct 39 ms 63880 KB Output is correct
33 Correct 40 ms 63864 KB Output is correct
34 Correct 38 ms 63864 KB Output is correct
35 Correct 41 ms 63864 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 63864 KB Output is correct
2 Correct 38 ms 63840 KB Output is correct
3 Correct 39 ms 63868 KB Output is correct
4 Correct 39 ms 63864 KB Output is correct
5 Correct 41 ms 63864 KB Output is correct
6 Correct 37 ms 63864 KB Output is correct
7 Correct 40 ms 63900 KB Output is correct
8 Correct 39 ms 63864 KB Output is correct
9 Correct 38 ms 63868 KB Output is correct
10 Correct 40 ms 63864 KB Output is correct
11 Correct 39 ms 63864 KB Output is correct
12 Correct 38 ms 63864 KB Output is correct
13 Correct 40 ms 63864 KB Output is correct
14 Correct 38 ms 63864 KB Output is correct
15 Correct 39 ms 63864 KB Output is correct
16 Correct 38 ms 63868 KB Output is correct
17 Correct 40 ms 63864 KB Output is correct
18 Correct 77 ms 63868 KB Output is correct
19 Correct 56 ms 63864 KB Output is correct
20 Correct 45 ms 63864 KB Output is correct
21 Correct 54 ms 63864 KB Output is correct
22 Correct 61 ms 63864 KB Output is correct
23 Correct 45 ms 63864 KB Output is correct
24 Correct 43 ms 63864 KB Output is correct
25 Correct 45 ms 63864 KB Output is correct
26 Correct 40 ms 63864 KB Output is correct
27 Correct 44 ms 63864 KB Output is correct
28 Correct 43 ms 63864 KB Output is correct
29 Correct 44 ms 63864 KB Output is correct
30 Correct 42 ms 63824 KB Output is correct
31 Correct 45 ms 63992 KB Output is correct
32 Correct 41 ms 63864 KB Output is correct
33 Correct 43 ms 63864 KB Output is correct
34 Correct 39 ms 63864 KB Output is correct
35 Correct 45 ms 63864 KB Output is correct
36 Correct 40 ms 63864 KB Output is correct
37 Correct 45 ms 63864 KB Output is correct
38 Correct 41 ms 63864 KB Output is correct
39 Correct 45 ms 63864 KB Output is correct
40 Correct 41 ms 63864 KB Output is correct
41 Correct 88 ms 63864 KB Output is correct
42 Correct 64 ms 63864 KB Output is correct
43 Correct 94 ms 63992 KB Output is correct
44 Correct 63 ms 63864 KB Output is correct
45 Correct 86 ms 63864 KB Output is correct
46 Correct 65 ms 63864 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 63864 KB Output is correct
2 Correct 38 ms 63840 KB Output is correct
3 Correct 39 ms 63868 KB Output is correct
4 Correct 39 ms 63864 KB Output is correct
5 Correct 41 ms 63864 KB Output is correct
6 Correct 37 ms 63864 KB Output is correct
7 Correct 40 ms 63900 KB Output is correct
8 Correct 39 ms 63864 KB Output is correct
9 Correct 38 ms 63868 KB Output is correct
10 Correct 40 ms 63864 KB Output is correct
11 Correct 39 ms 63864 KB Output is correct
12 Correct 38 ms 63864 KB Output is correct
13 Correct 40 ms 63864 KB Output is correct
14 Correct 38 ms 63864 KB Output is correct
15 Correct 39 ms 63864 KB Output is correct
16 Correct 38 ms 63868 KB Output is correct
17 Correct 40 ms 63864 KB Output is correct
18 Correct 37 ms 63864 KB Output is correct
19 Correct 39 ms 63892 KB Output is correct
20 Correct 40 ms 63868 KB Output is correct
21 Correct 38 ms 63992 KB Output is correct
22 Correct 38 ms 63864 KB Output is correct
23 Correct 42 ms 63864 KB Output is correct
24 Correct 39 ms 63864 KB Output is correct
25 Correct 39 ms 63864 KB Output is correct
26 Correct 38 ms 63864 KB Output is correct
27 Correct 41 ms 63864 KB Output is correct
28 Correct 38 ms 63868 KB Output is correct
29 Correct 40 ms 63864 KB Output is correct
30 Correct 38 ms 63864 KB Output is correct
31 Correct 38 ms 63864 KB Output is correct
32 Correct 39 ms 63880 KB Output is correct
33 Correct 40 ms 63864 KB Output is correct
34 Correct 38 ms 63864 KB Output is correct
35 Correct 41 ms 63864 KB Output is correct
36 Correct 77 ms 63868 KB Output is correct
37 Correct 56 ms 63864 KB Output is correct
38 Correct 45 ms 63864 KB Output is correct
39 Correct 54 ms 63864 KB Output is correct
40 Correct 61 ms 63864 KB Output is correct
41 Correct 45 ms 63864 KB Output is correct
42 Correct 43 ms 63864 KB Output is correct
43 Correct 45 ms 63864 KB Output is correct
44 Correct 40 ms 63864 KB Output is correct
45 Correct 44 ms 63864 KB Output is correct
46 Correct 43 ms 63864 KB Output is correct
47 Correct 44 ms 63864 KB Output is correct
48 Correct 42 ms 63824 KB Output is correct
49 Correct 45 ms 63992 KB Output is correct
50 Correct 41 ms 63864 KB Output is correct
51 Correct 43 ms 63864 KB Output is correct
52 Correct 39 ms 63864 KB Output is correct
53 Correct 45 ms 63864 KB Output is correct
54 Correct 40 ms 63864 KB Output is correct
55 Correct 45 ms 63864 KB Output is correct
56 Correct 41 ms 63864 KB Output is correct
57 Correct 45 ms 63864 KB Output is correct
58 Correct 41 ms 63864 KB Output is correct
59 Correct 88 ms 63864 KB Output is correct
60 Correct 64 ms 63864 KB Output is correct
61 Correct 94 ms 63992 KB Output is correct
62 Correct 63 ms 63864 KB Output is correct
63 Correct 86 ms 63864 KB Output is correct
64 Correct 65 ms 63864 KB Output is correct
65 Correct 80 ms 63868 KB Output is correct
66 Correct 78 ms 63992 KB Output is correct
67 Correct 74 ms 63864 KB Output is correct
68 Correct 69 ms 63864 KB Output is correct
69 Correct 82 ms 63864 KB Output is correct
70 Correct 78 ms 63828 KB Output is correct
71 Correct 80 ms 63864 KB Output is correct
72 Correct 80 ms 63864 KB Output is correct
73 Correct 73 ms 63864 KB Output is correct
74 Correct 74 ms 63864 KB Output is correct
75 Correct 77 ms 63888 KB Output is correct
76 Correct 89 ms 63984 KB Output is correct
77 Correct 84 ms 63864 KB Output is correct
78 Incorrect 70 ms 63864 KB Output isn't correct
79 Halted 0 ms 0 KB -