답안 #581197

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
581197 2022-06-22T11:08:42 Z chirathnirodha Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
109 ms 17116 KB
//Coded by Chirath Nirodha
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define P push
#define I insert
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
const ll mod=1e9+7;
inline void io(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}
void solve(){
    io();
	int n;cin>>n;
	ll a[n+1],b[n],c[n+1];
	ll arr[n],brr[n];
	vector<pair<ll,ll> > v;
	for(int i=0;i<=n;i++){cin>>a[i];v.PB(MP(a[i],i));}
	for(int i=0;i<n;i++)cin>>b[i];
	sort(a,a+n+1);
	sort(b,b+n);
	sort(v.begin(),v.end());
	for(int i=0;i<n;i++){
		arr[i]=max(a[i]-b[i],ll(0));
		brr[n-1-i]=max(a[n-i]-b[n-1-i],ll(0));
		if(i==0)continue;
		arr[i]=max(arr[i],arr[i-1]);
		brr[n-1-i]=max(brr[n-1-i],brr[n-i]);
	}
	c[v[0].S]=brr[0];
	c[v[n].S]=arr[n-1];
	for(int i=1;i<n;i++){
		c[v[i].S]=max(arr[i-1],brr[i]);
	}
	for(int i=0;i<=n;i++)cout<<c[i]<<" ";cout<<endl;
}
int main(){
    io();
	solve();
	//int t;cin>>t;for(int i=0;i<t;i++)solve();
    return 0;
}

Compilation message

ho_t1.cpp: In function 'void solve()':
ho_t1.cpp:45:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   45 |  for(int i=0;i<=n;i++)cout<<c[i]<<" ";cout<<endl;
      |  ^~~
ho_t1.cpp:45:39: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   45 |  for(int i=0;i<=n;i++)cout<<c[i]<<" ";cout<<endl;
      |                                       ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 324 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 324 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 480 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 ms 468 KB Output is correct
21 Correct 1 ms 460 KB Output is correct
22 Correct 2 ms 444 KB Output is correct
23 Correct 1 ms 468 KB Output is correct
24 Correct 1 ms 468 KB Output is correct
25 Correct 1 ms 468 KB Output is correct
26 Correct 2 ms 484 KB Output is correct
27 Correct 2 ms 468 KB Output is correct
28 Correct 1 ms 468 KB Output is correct
29 Correct 1 ms 468 KB Output is correct
30 Correct 2 ms 456 KB Output is correct
31 Correct 2 ms 468 KB Output is correct
32 Correct 1 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 324 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 480 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 ms 468 KB Output is correct
21 Correct 1 ms 460 KB Output is correct
22 Correct 2 ms 444 KB Output is correct
23 Correct 1 ms 468 KB Output is correct
24 Correct 1 ms 468 KB Output is correct
25 Correct 1 ms 468 KB Output is correct
26 Correct 2 ms 484 KB Output is correct
27 Correct 2 ms 468 KB Output is correct
28 Correct 1 ms 468 KB Output is correct
29 Correct 1 ms 468 KB Output is correct
30 Correct 2 ms 456 KB Output is correct
31 Correct 2 ms 468 KB Output is correct
32 Correct 1 ms 468 KB Output is correct
33 Correct 100 ms 16004 KB Output is correct
34 Correct 109 ms 16704 KB Output is correct
35 Correct 105 ms 16316 KB Output is correct
36 Correct 103 ms 16716 KB Output is correct
37 Correct 107 ms 17116 KB Output is correct
38 Correct 108 ms 16952 KB Output is correct
39 Correct 98 ms 16016 KB Output is correct
40 Correct 104 ms 15968 KB Output is correct
41 Correct 102 ms 16076 KB Output is correct
42 Correct 97 ms 16068 KB Output is correct
43 Correct 99 ms 15984 KB Output is correct
44 Correct 98 ms 15404 KB Output is correct
45 Correct 102 ms 15572 KB Output is correct
46 Correct 99 ms 15344 KB Output is correct
47 Correct 91 ms 15912 KB Output is correct
48 Correct 94 ms 15900 KB Output is correct
49 Correct 104 ms 16448 KB Output is correct
50 Correct 103 ms 16456 KB Output is correct
51 Correct 108 ms 16556 KB Output is correct
52 Correct 104 ms 16380 KB Output is correct
53 Correct 101 ms 16348 KB Output is correct