답안 #1094364

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1094364 2024-09-29T12:44:17 Z imarn Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
75 ms 10836 KB
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define plx pair<ll,int>
#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vi>
using namespace std;
const int mxn=2e5+5;
int t[2*mxn]{0};
void upd(int i,int amt,int sz){
    i+=sz;t[i]=amt;
    for(i>>=1;i;i>>=1)t[i]=max(t[2*i],t[2*i+1]);
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;cin>>n;pii a[n+1];int b[n];
    for(int i=0;i<n+1;i++)cin>>a[i].f,a[i].s=i;
    for(int i=0;i<n;i++)cin>>b[i];sort(a,a+n+1);sort(b,b+n);
    for(int i=0;i<n;i++)t[i+n]=a[i+1].f-b[i];
    for(int i=n-1;i>0;i--)t[i]=max(t[2*i],t[2*i+1]);
    int rs[n+1]={0};
    for(int i=0;i<n+1;i++){
        rs[a[i].s] = max(t[1],0);upd(i,a[i].f-b[i],n);
    }for(int i=0;i<n+1;i++)cout<<rs[i]<<' ';
}

Compilation message

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:26:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   26 |     for(int i=0;i<n;i++)cin>>b[i];sort(a,a+n+1);sort(b,b+n);
      |     ^~~
ho_t1.cpp:26:35: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   26 |     for(int i=0;i<n;i++)cin>>b[i];sort(a,a+n+1);sort(b,b+n);
      |                                   ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 468 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 468 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 504 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 472 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 624 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 468 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 504 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 472 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 624 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 65 ms 9956 KB Output is correct
34 Correct 68 ms 10308 KB Output is correct
35 Correct 71 ms 10000 KB Output is correct
36 Correct 75 ms 10508 KB Output is correct
37 Correct 74 ms 10832 KB Output is correct
38 Correct 69 ms 10836 KB Output is correct
39 Correct 67 ms 9764 KB Output is correct
40 Correct 67 ms 9808 KB Output is correct
41 Correct 71 ms 9908 KB Output is correct
42 Correct 70 ms 9808 KB Output is correct
43 Correct 70 ms 9808 KB Output is correct
44 Correct 68 ms 9296 KB Output is correct
45 Correct 68 ms 9552 KB Output is correct
46 Correct 68 ms 9296 KB Output is correct
47 Correct 65 ms 9400 KB Output is correct
48 Correct 65 ms 9564 KB Output is correct
49 Correct 71 ms 9988 KB Output is correct
50 Correct 72 ms 10064 KB Output is correct
51 Correct 71 ms 10064 KB Output is correct
52 Correct 71 ms 10068 KB Output is correct
53 Correct 70 ms 10084 KB Output is correct