답안 #337162

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
337162 2020-12-18T16:50:54 Z ryansee Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
300 ms 21868 KB
#include "bits/stdc++.h"
using namespace std;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x,y) (lower_bound(all(x),y)-x.begin())
#define ubd(x,y) (upper_bound(all(x),y)-x.begin())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return (rng() % (y+1-x)) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

typedef long long ll; 
typedef long double ld;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
typedef pair<ll,ll>pi; typedef pair<ll,pi>spi; typedef pair<pi,pi>dpi;

#define LLINF ((long long)1e18)
#define INF int(1e9+1e6)
#define MAXN (300006)
ll n,B[MAXN],ans[MAXN];
pi A[MAXN];
int main(){
	FAST
	cin>>n;
	FOR(i,1,n+1)cin>>A[i].f,A[i].s=i;
	FOR(i,1,n)cin>>B[i];
	sort(B+1,B+n+1), sort(A+1,A+n+2);
	ll p_mx=-LLINF;
	multiset<ll> ms;
	ms.ins(-LLINF);
	FOR(i,1,n)ms.ins(A[i+1].f-B[i]);
	ans[A[1].s]=*--ms.end();
	FOR(i,2,n+1){
		ms.erase(ms.find(A[i].f-B[i-1]));
		p_mx=max(p_mx,(A[i-1].f-B[i-1]));
		ans[A[i].s]=max(p_mx,*--ms.end());
	}
	FOR(i,1,n+1)cout<<max(0ll,ans[i])<<' ';cout<<'\n';
}

Compilation message

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:22:20: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   22 | #define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
      |                    ^~~
ho_t1.cpp:47:2: note: in expansion of macro 'FOR'
   47 |  FOR(i,1,n+1)cout<<max(0ll,ans[i])<<' ';cout<<'\n';
      |  ^~~
ho_t1.cpp:47:41: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   47 |  FOR(i,1,n+1)cout<<max(0ll,ans[i])<<' ';cout<<'\n';
      |                                         ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 492 KB Output is correct
15 Correct 2 ms 492 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 2 ms 620 KB Output is correct
18 Correct 2 ms 492 KB Output is correct
19 Correct 2 ms 492 KB Output is correct
20 Correct 2 ms 492 KB Output is correct
21 Correct 2 ms 492 KB Output is correct
22 Correct 2 ms 492 KB Output is correct
23 Correct 2 ms 492 KB Output is correct
24 Correct 2 ms 512 KB Output is correct
25 Correct 2 ms 620 KB Output is correct
26 Correct 2 ms 620 KB Output is correct
27 Correct 2 ms 620 KB Output is correct
28 Correct 2 ms 620 KB Output is correct
29 Correct 2 ms 492 KB Output is correct
30 Correct 2 ms 492 KB Output is correct
31 Correct 2 ms 620 KB Output is correct
32 Correct 2 ms 620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 492 KB Output is correct
15 Correct 2 ms 492 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 2 ms 620 KB Output is correct
18 Correct 2 ms 492 KB Output is correct
19 Correct 2 ms 492 KB Output is correct
20 Correct 2 ms 492 KB Output is correct
21 Correct 2 ms 492 KB Output is correct
22 Correct 2 ms 492 KB Output is correct
23 Correct 2 ms 492 KB Output is correct
24 Correct 2 ms 512 KB Output is correct
25 Correct 2 ms 620 KB Output is correct
26 Correct 2 ms 620 KB Output is correct
27 Correct 2 ms 620 KB Output is correct
28 Correct 2 ms 620 KB Output is correct
29 Correct 2 ms 492 KB Output is correct
30 Correct 2 ms 492 KB Output is correct
31 Correct 2 ms 620 KB Output is correct
32 Correct 2 ms 620 KB Output is correct
33 Correct 178 ms 20460 KB Output is correct
34 Correct 183 ms 21356 KB Output is correct
35 Correct 185 ms 20716 KB Output is correct
36 Correct 176 ms 21228 KB Output is correct
37 Correct 183 ms 21868 KB Output is correct
38 Correct 189 ms 21740 KB Output is correct
39 Correct 287 ms 20588 KB Output is correct
40 Correct 278 ms 20460 KB Output is correct
41 Correct 270 ms 20588 KB Output is correct
42 Correct 295 ms 20716 KB Output is correct
43 Correct 300 ms 20460 KB Output is correct
44 Correct 142 ms 19948 KB Output is correct
45 Correct 150 ms 20076 KB Output is correct
46 Correct 140 ms 19948 KB Output is correct
47 Correct 144 ms 20588 KB Output is correct
48 Correct 155 ms 20588 KB Output is correct
49 Correct 277 ms 21100 KB Output is correct
50 Correct 284 ms 21100 KB Output is correct
51 Correct 274 ms 21100 KB Output is correct
52 Correct 284 ms 21228 KB Output is correct
53 Correct 290 ms 21100 KB Output is correct