답안 #969634

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
969634 2024-04-25T11:38:12 Z firewater Measures (CEOI22_measures) C++14
24 / 100
133 ms 12624 KB
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,m,D,x,ans,b[202400];
set<tuple<ll,ll,ll> >s;
void add(ll v)
{
	ll l=v,r=v,sz=1,L,R,SZ;
	auto it=s.lower_bound({l,r,1ll});
	if(it!=s.begin()){
		it--;
		tie(L,R,SZ)=*it;
		if(l<=R+D){
			l=min(l,L);
			r=max(r,R);
			sz+=SZ;
			s.erase(it);
		}
	}
	it=s.lower_bound({l,r,1ll});
	if(it!=s.end()){
		tie(L,R,SZ)=*it;
		if(L<=r+D){
			l=min(l,L);
			r=max(r,R);
			sz+=SZ;
			s.erase(it);
		}
	}
	s.insert({l,r,sz});
	ans=max(ans,(sz-1)*D+1-(r-l+1));
	return;
}
int main()
{
	scanf("%lld%lld%lld",&n,&m,&D);
	ans=0;
	for(ll i=1;i<=n;++i){
		scanf("%lld",&x);
		add(x);
	}
  	for(ll i=1;i<=m;++i)
    	scanf("%lld",&b[i]);
	for(ll i=1;i<=m;++i){
      	if(i>1)putchar(32);
		add(b[i]);
		if(ans&1)printf("%lld.5",ans/2);
		else printf("%lld",ans/2);
	}
	putchar(10);
	return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:36:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |  scanf("%lld%lld%lld",&n,&m,&D);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:39:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |   scanf("%lld",&x);
      |   ~~~~~^~~~~~~~~~~
Main.cpp:43:11: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 |      scanf("%lld",&b[i]);
      |      ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 133 ms 12456 KB Output is correct
10 Correct 33 ms 348 KB Output is correct
11 Correct 31 ms 448 KB Output is correct
12 Correct 33 ms 348 KB Output is correct
13 Correct 30 ms 348 KB Output is correct
14 Correct 82 ms 10656 KB Output is correct
15 Correct 107 ms 3380 KB Output is correct
16 Correct 33 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 106 ms 12624 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 106 ms 12624 KB Output isn't correct
2 Halted 0 ms 0 KB -