답안 #222589

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
222589 2020-04-13T11:24:23 Z Fshoaib Collecting Stamps 3 (JOI20_ho_t3) C++11
0 / 100
5 ms 384 KB
#include "bits/stdc++.h"
using namespace std;
/*ios_base::sync_with_stdio(false);
    cin.tie(NULL);*/
    
typedef long long ll;
 
 
 ll sta = 0; 
 ll N, L; 
 ll h = -1; 
pair<ll,ll> stamps[205];
ll s; 
 void search(set<ll> vis, ll idx, ll prev, ll time){
	  
	 if (stamps[idx].first == -1){
	 } else if (vis.size() == N){
		 sta = N; 
		 for(int i =0; i < 205; i++){
			stamps[i] = make_pair(-1,-1); 
		 } 
	 } else if (time > h) {
	 } else { //edge cases 
		 ll beg = vis.size();
		 if (time <= stamps[idx].second){
			 vis.insert(idx); 
		 } 
		 
		 if (vis.size() > sta){
			 sta = vis.size(); 
		 }
		 
		 ll bak = idx - 1; 
		 ll db = stamps[idx].first - stamps[bak].first; 
		 if (bak < 0){
			 bak = s - 1; 
			 db = L - stamps[bak].first + stamps[idx].first; 
		 } 
		 
		 ll fron = idx + 1; 
		 ll df = stamps[fron].first - stamps[idx].first; 
		 if (fron >= s){
			 fron = 0; 
			 df = L - stamps[idx].first + stamps[fron].first; 
		 }
		 if (beg == vis.size()){
			 if (prev != bak){
				 search(vis, bak, idx, db + time); 
			 }
			 if (prev != fron){
				 search(vis, fron, idx, df + time); 
			 }
		 } else {
			 search(vis, bak, idx, db + time); 
			 search(vis, fron, idx, df + time); 
		 }
	 }
	 
	 
	 
	 
 }
 
int main( )
{	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    for(int i =0; i < 205; i++){
		stamps[i] = make_pair(-1,-1); 
	}
	
	cin >> N >> L; 
	ll p[N];
	ll t[N]; 
	for(int i=0; i < N; i++){
		cin >> p[i]; 
	}
	for(int i=0; i < N; i++){
		cin >> t[i]; 
		h = max(t[i],h); 
	}
	s = 0; 
	priority_queue<pair<ll,ll> > st; 
	for(int i=0; i < N; i++){
		if (min(L - p[i], p[i]) <= t[i]){
			st.push(make_pair(-p[i],-t[i])); 
			s++; 
		}
	}
	
	ll r = -1; 
	while (st.size() > 0){
		r++; 
		stamps[r] = make_pair(-st.top().first, -st.top().second); 
		st.pop();
	}
	
	
	set<ll> ini; 
	if (s > 0) {
		search(ini, 0, -1, min(L - p[0], p[0])); 
		
	}
	if (s > 1){
		search(ini, s-1, -1, min(L - p[s-1], p[s-1])); 
	}
	
	cout << sta; 
	
   
}

Compilation message

ho_t3.cpp: In function 'void search(std::set<long long int>, ll, ll, ll)':
ho_t3.cpp:17:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   } else if (vis.size() == N){
              ~~~~~~~~~~~^~~~
ho_t3.cpp:29:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if (vis.size() > sta){
        ~~~~~~~~~~~^~~~~
ho_t3.cpp:46:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if (beg == vis.size()){
        ~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Incorrect 5 ms 384 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Incorrect 5 ms 384 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Incorrect 5 ms 384 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Incorrect 5 ms 384 KB Output isn't correct
5 Halted 0 ms 0 KB -