답안 #217113

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
217113 2020-03-29T02:00:58 Z jamielim Collecting Stamps 3 (JOI20_ho_t3) C++14
0 / 100
5 ms 256 KB
#include <bits/stdc++.h>
using namespace std;

int main(){
	int n,l;
	scanf("%d%d",&n,&l);
	int x[n],t[n];
	for(int i=0;i<n;i++)scanf("%d",&x[i]);
	for(int i=0;i<n;i++)scanf("%d",&t[i]);
	int ans=0;
	for(int i=-1;i<n;i++){
		int cur=0;
		for(int j=0;j<=i;j++){
			if(x[j]<=t[j])cur++;
		}
		for(int j=n-1;j>i;j--){
			if(l-x[j]+2*(i==-1?0:x[i])<=t[j])cur++;
		}
		ans=max(ans,cur);
		cur=0;
		for(int j=n-1;j>i;j--){
			if(l-x[j]<=t[j])cur++;
		}
		for(int j=0;j<=i;j++){
			if(x[j]+2*(l-(i==n-1?0:x[i+1]))<=t[j])cur++;
		}
		ans=max(ans,cur);
	}
	printf("%d",ans);
}

Compilation message

ho_t3.cpp: In function 'int main()':
ho_t3.cpp:6:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&n,&l);
  ~~~~~^~~~~~~~~~~~~~
ho_t3.cpp:8:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=0;i<n;i++)scanf("%d",&x[i]);
                      ~~~~~^~~~~~~~~~~~
ho_t3.cpp:9:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=0;i<n;i++)scanf("%d",&t[i]);
                      ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB Output is correct
2 Incorrect 5 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB Output is correct
2 Incorrect 5 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB Output is correct
2 Incorrect 5 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB Output is correct
2 Incorrect 5 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -