# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
877451 | 2023-11-23T08:45:59 Z | hasan2006 | Just Long Neckties (JOI20_ho_t1) | C++17 | 202 ms | 31532 KB |
#include <bits/stdc++.h> using namespace std; #define TL ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); #define rall(s) s.rbegin(),s.rend() #define all(s) s.begin(),s.end() #define pb push_back #define se second #define fi first #define ll long long #define ld long double #define YES cout<<"YES\n" #define Yes cout<<"Yes\n" #define yes cout<<"yes\n" #define NO cout<<"NO\n" #define No cout<<"No\n" #define no cout<<"no\n" const int N = 5e5 + 9 , mod = 1e9 + 7; ll a[N] = {}, b[N] , c[N] , d[N] , dp[N]; void solve() { ll q , i , j , m ,n, z ,s = 0 , f, l , r , k , x , y , mn = 1e18 , mx = 0; cin>>n; vector<pair<int,int>>v; for(i = 1; i <= n + 1; i++){ cin>>x; v.pb({x , i}); } for(i = 1; i <= n; i++) cin>>a[i]; v.pb({0 , 0}); sort(all(v)); multiset<ll>st; sort(a + 1 , a + n + 1); for(i = 1; i <= n; i++){ d[i] = c[i] = v[i].fi - a[i]; d[i] += v[i + 1].fi - v[i].fi; st.insert(d[i]); } for(i = 1; i <= n; i++){ dp[v[i].se] = *st.rbegin(); st.erase(st.find(d[i])); st.insert(c[i]); } dp[v[n + 1].se] = *st.rbegin(); for(i = 1; i <= n + 1; i++) cout<<dp[i]<<" "; } int main(){ TL; /* #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif*/ int t = 1; //cin>>t; while(t--) { solve(); } } // Author : حسن
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 6748 KB | Output is correct |
2 | Correct | 1 ms | 6492 KB | Output is correct |
3 | Correct | 1 ms | 6488 KB | Output is correct |
4 | Correct | 1 ms | 6492 KB | Output is correct |
5 | Correct | 1 ms | 6492 KB | Output is correct |
6 | Correct | 1 ms | 6492 KB | Output is correct |
7 | Correct | 1 ms | 6492 KB | Output is correct |
8 | Correct | 1 ms | 6492 KB | Output is correct |
9 | Correct | 1 ms | 6492 KB | Output is correct |
10 | Correct | 1 ms | 6492 KB | Output is correct |
11 | Correct | 1 ms | 6492 KB | Output is correct |
12 | Correct | 1 ms | 6492 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 6748 KB | Output is correct |
2 | Correct | 1 ms | 6492 KB | Output is correct |
3 | Correct | 1 ms | 6488 KB | Output is correct |
4 | Correct | 1 ms | 6492 KB | Output is correct |
5 | Correct | 1 ms | 6492 KB | Output is correct |
6 | Correct | 1 ms | 6492 KB | Output is correct |
7 | Correct | 1 ms | 6492 KB | Output is correct |
8 | Correct | 1 ms | 6492 KB | Output is correct |
9 | Correct | 1 ms | 6492 KB | Output is correct |
10 | Correct | 1 ms | 6492 KB | Output is correct |
11 | Correct | 1 ms | 6492 KB | Output is correct |
12 | Correct | 1 ms | 6492 KB | Output is correct |
13 | Correct | 2 ms | 6488 KB | Output is correct |
14 | Correct | 2 ms | 6492 KB | Output is correct |
15 | Correct | 2 ms | 6748 KB | Output is correct |
16 | Correct | 1 ms | 6492 KB | Output is correct |
17 | Correct | 2 ms | 6748 KB | Output is correct |
18 | Correct | 2 ms | 6748 KB | Output is correct |
19 | Correct | 2 ms | 6748 KB | Output is correct |
20 | Correct | 2 ms | 6748 KB | Output is correct |
21 | Correct | 2 ms | 6744 KB | Output is correct |
22 | Correct | 3 ms | 6748 KB | Output is correct |
23 | Correct | 2 ms | 6748 KB | Output is correct |
24 | Correct | 2 ms | 6748 KB | Output is correct |
25 | Correct | 2 ms | 6748 KB | Output is correct |
26 | Correct | 2 ms | 6676 KB | Output is correct |
27 | Correct | 2 ms | 6748 KB | Output is correct |
28 | Correct | 2 ms | 6624 KB | Output is correct |
29 | Correct | 2 ms | 6748 KB | Output is correct |
30 | Correct | 2 ms | 6624 KB | Output is correct |
31 | Correct | 2 ms | 6748 KB | Output is correct |
32 | Correct | 2 ms | 6620 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 6748 KB | Output is correct |
2 | Correct | 1 ms | 6492 KB | Output is correct |
3 | Correct | 1 ms | 6488 KB | Output is correct |
4 | Correct | 1 ms | 6492 KB | Output is correct |
5 | Correct | 1 ms | 6492 KB | Output is correct |
6 | Correct | 1 ms | 6492 KB | Output is correct |
7 | Correct | 1 ms | 6492 KB | Output is correct |
8 | Correct | 1 ms | 6492 KB | Output is correct |
9 | Correct | 1 ms | 6492 KB | Output is correct |
10 | Correct | 1 ms | 6492 KB | Output is correct |
11 | Correct | 1 ms | 6492 KB | Output is correct |
12 | Correct | 1 ms | 6492 KB | Output is correct |
13 | Correct | 2 ms | 6488 KB | Output is correct |
14 | Correct | 2 ms | 6492 KB | Output is correct |
15 | Correct | 2 ms | 6748 KB | Output is correct |
16 | Correct | 1 ms | 6492 KB | Output is correct |
17 | Correct | 2 ms | 6748 KB | Output is correct |
18 | Correct | 2 ms | 6748 KB | Output is correct |
19 | Correct | 2 ms | 6748 KB | Output is correct |
20 | Correct | 2 ms | 6748 KB | Output is correct |
21 | Correct | 2 ms | 6744 KB | Output is correct |
22 | Correct | 3 ms | 6748 KB | Output is correct |
23 | Correct | 2 ms | 6748 KB | Output is correct |
24 | Correct | 2 ms | 6748 KB | Output is correct |
25 | Correct | 2 ms | 6748 KB | Output is correct |
26 | Correct | 2 ms | 6676 KB | Output is correct |
27 | Correct | 2 ms | 6748 KB | Output is correct |
28 | Correct | 2 ms | 6624 KB | Output is correct |
29 | Correct | 2 ms | 6748 KB | Output is correct |
30 | Correct | 2 ms | 6624 KB | Output is correct |
31 | Correct | 2 ms | 6748 KB | Output is correct |
32 | Correct | 2 ms | 6620 KB | Output is correct |
33 | Correct | 165 ms | 30628 KB | Output is correct |
34 | Correct | 158 ms | 31144 KB | Output is correct |
35 | Correct | 139 ms | 30648 KB | Output is correct |
36 | Correct | 147 ms | 31112 KB | Output is correct |
37 | Correct | 149 ms | 31532 KB | Output is correct |
38 | Correct | 139 ms | 31428 KB | Output is correct |
39 | Correct | 187 ms | 30448 KB | Output is correct |
40 | Correct | 185 ms | 30496 KB | Output is correct |
41 | Correct | 182 ms | 30660 KB | Output is correct |
42 | Correct | 190 ms | 30480 KB | Output is correct |
43 | Correct | 201 ms | 30392 KB | Output is correct |
44 | Correct | 152 ms | 29968 KB | Output is correct |
45 | Correct | 138 ms | 30060 KB | Output is correct |
46 | Correct | 154 ms | 30072 KB | Output is correct |
47 | Correct | 127 ms | 30288 KB | Output is correct |
48 | Correct | 125 ms | 30444 KB | Output is correct |
49 | Correct | 202 ms | 30836 KB | Output is correct |
50 | Correct | 186 ms | 30840 KB | Output is correct |
51 | Correct | 199 ms | 30840 KB | Output is correct |
52 | Correct | 196 ms | 30852 KB | Output is correct |
53 | Correct | 192 ms | 30856 KB | Output is correct |