Submission #1088769

#TimeUsernameProblemLanguageResultExecution timeMemory
1088769ntdaccodeJust Long Neckties (JOI20_ho_t1)C++17
100 / 100
74 ms15648 KiB
//de y tung cac mang 1 #include<bits/stdc++.h> #define fori(i,a,b) for(int i=a;i<=b;i++) #define int long long #define pb push_back #define ii pair<int,int> #define fi first #define se second using namespace std; const int M=2e5+10; int n,b[M],ret[M],f[M],g[M]; ii a[M]; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if(fopen("1.inp","r")) { freopen("1.inp","r",stdin); freopen("1.out","w",stdout); } cin >> n; fori(i,1,n+1) { cin >> a[i].fi; a[i].se=i; } fori(i,1,n) cin >> b[i]; sort(a+1,a+n+2); sort(b+1,b+n+1); //fori(i,1,n+1) cout << a[i] << " "; fori(i,1,n) f[i]=max(f[i-1],max(0ll,a[i].fi-b[i])); for(int i=n+1;i!=1;i--) g[i]=max(g[i+1],max(0ll,a[i].fi-b[i-1])); fori(i,1,n+1) ret[a[i].se]=max(f[i-1],g[i+1]); fori(i,1,n+1) cout << ret[i] << " "; }

Compilation message (stderr)

ho_t1.cpp: In function 'int32_t main()':
ho_t1.cpp:20:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |     freopen("1.inp","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~
ho_t1.cpp:21:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |     freopen("1.out","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...