Submission #1040030

#TimeUsernameProblemLanguageResultExecution timeMemory
1040030MrPavlitoJust Long Neckties (JOI20_ho_t1)C++17
100 / 100
62 ms11628 KiB
#include <bits/stdc++.h> //#define int long long #define pb push_back #define mp make_pair #define all(x) (x).begin(),(x).end() #define fi first #define sc second #define endl "\n" #define pii pair<int,int> using namespace std; const int MAXN = 1e5+5; const int mod7 = 1e9+7; const long long inf = 1e18; signed main() { ios_base::sync_with_stdio(false),cin.tie(0), cout.tie(0); int tt=1; //cin >> tt; while(tt--) { int n; cin >> n; vector<pii>a(n+1); vector<int>b(n); for(int i=0; i<=n; i++) { cin >> a[i].fi; a[i].sc = i; } for(int i=0; i<n; i++)cin >> b[i]; sort(all(b)); sort(all(a)); vector<int> razlika(n); for(int i=0; i<n; i++)razlika[i] = a[i+1].fi - b[i]; vector<int> prefmax(n+1,0); vector<int> sufmax(n+1,0); for(int i=n-1; i>=0; i--)sufmax[i] = max(sufmax[i+1], razlika[i]); vector<int> rez(n+1); rez[a[0].sc] = sufmax[0]; for(int i=1; i<=n; i++) { prefmax[i] = max(prefmax[i-1], a[i-1].fi - b[i-1]); rez[a[i].sc] = max(prefmax[i], sufmax[i]); } //for(auto x:prefmax)cout << x << " ";cout <<endl; //for(auto x:sufmax)cout << x << " ";cout <<endl; for(auto x:rez)cout << x << " ";cout <<endl; } }

Compilation message (stderr)

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:51:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   51 |         for(auto x:rez)cout << x << " ";cout <<endl;
      |         ^~~
ho_t1.cpp:51:41: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   51 |         for(auto x:rez)cout << x << " ";cout <<endl;
      |                                         ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...