제출 #1115175

#제출 시각아이디문제언어결과실행 시간메모리
1115175staszic_ojuzJust Long Neckties (JOI20_ho_t1)C++17
100 / 100
82 ms10808 KiB
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    vector<pair<int, int>> neckties(n+1);
    for (int i=0;i<n+1;i++){
        cin>>neckties[i].first;
        neckties[i].second=i;
    }
    vector<int> employees(n);
    for (int i=0;i<n;i++) cin>>employees[i];
    sort(neckties.begin(), neckties.end(), greater<pair<int, int>>());
    sort(employees.begin(), employees.end(), greater<int>());
    vector<int> pref(n);
    pref[0]=max(0, neckties[0].first-employees[0]);
    for (int i=1;i<n;i++){
        pref[i]=max(pref[i-1], max(0, neckties[i].first-employees[i]));
    }
    vector<int> suff(n);
    suff[n-1]=max(0, neckties[n].first-employees[n-1]);
    for (int i=n-2;i>=0;i--){
        suff[i]=max(suff[i+1], max(0, neckties[i+1].first-employees[i]));
    }
    vector<int> out(n+1);
    for (int i=0;i<n+1;i++){
        int pr=0, sf=0;
        if (i>0) pr=pref[i-1];
        if (i<n) sf=suff[i];(
        out[neckties[i].second]=max(pr, sf));
    }
    for (int x:out) cout<<x<<" ";
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:35:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   35 |         if (i<n) sf=suff[i];(
      |         ^~
ho_t1.cpp:35:29: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   35 |         if (i<n) sf=suff[i];(
      |                             ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...