답안 #647303

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
647303 2022-10-02T07:14:42 Z ck_platypus Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
92 ms 13932 KB
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <utility>
#include <bitset>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <queue>
#include <cstring>
#include <fstream>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define pll pair<ll, ll>
#define plpll pair<ll, pll>
#define pii pair<int, int>
#define f first
#define s second
#define inf 1000000000000000
#define endl '\n'
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n;
    cin >> n;
    ll b[n];
    pll a[n+1];
    for(int i=0;i<n+1;i++) cin >> a[i].f, a[i].s=i;
    sort(a, a+n+1);
    for(int i=0;i<n;i++) cin >> b[i];
    sort(b, b+n);
    ll mx[n];
    mx[n-1]=max(0ll, a[n].f-b[n-1]);
    for(int i=n-2;i>=0;i--){
        mx[i]=max(mx[i+1], a[i+1].f-b[i]);
    }
    ll ans[n+1], cool=0;
    for(int i=0;i<n;i++){
        ans[a[i].s]=max(cool, mx[i]);
        cool=max(cool, a[i].f-b[i]);
    }
    ans[a[n].s]=cool;
    for(int i=0;i<n+1;i++) cout << ans[i] << ' ';cout << endl;
    return 0;
}

Compilation message

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:47:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   47 |     for(int i=0;i<n+1;i++) cout << ans[i] << ' ';cout << endl;
      |     ^~~
ho_t1.cpp:47:50: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   47 |     for(int i=0;i<n+1;i++) cout << ans[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 212 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 320 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 320 KB Output is correct
9 Correct 1 ms 212 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 212 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 320 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 320 KB Output is correct
9 Correct 1 ms 212 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 324 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 2 ms 328 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 2 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 340 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 212 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 320 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 320 KB Output is correct
9 Correct 1 ms 212 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 324 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 2 ms 328 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 2 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 88 ms 12952 KB Output is correct
34 Correct 89 ms 13396 KB Output is correct
35 Correct 83 ms 12944 KB Output is correct
36 Correct 88 ms 13520 KB Output is correct
37 Correct 91 ms 13932 KB Output is correct
38 Correct 85 ms 13752 KB Output is correct
39 Correct 91 ms 12728 KB Output is correct
40 Correct 91 ms 12680 KB Output is correct
41 Correct 83 ms 12824 KB Output is correct
42 Correct 90 ms 12812 KB Output is correct
43 Correct 89 ms 12648 KB Output is correct
44 Correct 86 ms 12236 KB Output is correct
45 Correct 86 ms 12340 KB Output is correct
46 Correct 82 ms 12312 KB Output is correct
47 Correct 83 ms 12532 KB Output is correct
48 Correct 78 ms 12536 KB Output is correct
49 Correct 91 ms 13164 KB Output is correct
50 Correct 92 ms 13168 KB Output is correct
51 Correct 86 ms 13132 KB Output is correct
52 Correct 92 ms 13172 KB Output is correct
53 Correct 89 ms 13052 KB Output is correct