Submission #701982

#TimeUsernameProblemLanguageResultExecution timeMemory
701982huomark1001Just Long Neckties (JOI20_ho_t1)C++17
100 / 100
242 ms23336 KiB
#include<bits/stdc++.h> #include<random> using namespace std; template<typename T> void _do(T x){cerr<<x<<"\n";} template<typename T,typename ...U> void _do(T x,U ...y){cerr<<x<<", ";_do(y...);} #define dbg(...) cerr<<#__VA_ARGS__<<" = ";_do(__VA_ARGS__); #define float double #define ss(n) fixed<<setprecision(n) #define ll long long #define int ll #define IO ios::sync_with_stdio(false);cin.tie(0); #define ld long double #define pb push_back #define pii pair<int,int> #define rep(i,a) for(int i=1;i<=a;i++) #define rep0(i,a) for(int i=0;i<a;i++) #define F first #define S second #define uni(a) a.resize(distance(a.begin(),unique(a.begin(),a.end()))); #define unisort(a) sort(a.begin(),a.end()); uni(a); ll gcd(ll a,ll b){if(b==0) return a; return gcd(b,a%b);} const ld pi=3.14159265358979323846264338327950288419716939931; const int lar=3e18; const int mol1=1e9+7; const int mol2=998244353; const int MX=3e5; void solve() { int n; cin>>n; int a[n+2]; rep(i,n+1) cin>>a[i]; int b[n+1]; rep(i,n) cin>>b[i]; int ans[n+2]; vector<pair<int,int>>aa; rep(i,n+1){ aa.pb({a[i],i}); } sort(aa.begin(),aa.end()); sort(b+1,b+n+1); multiset<int,greater<>>all; rep0(i,aa.size()){ if(i==0) continue; int nn=aa[i].F; all.insert(nn-b[i]); } ans[aa[0].S]=*all.begin(); for(int i=1;i<aa.size();i++){ all.insert(aa[i-1].F-b[i]); all.erase(all.find(aa[i].F-b[i])); ans[aa[i].S]=*all.begin(); } rep(i,n+1) cout<<ans[i]<<" "; } signed main() { IO solve(); return 0; }

Compilation message (stderr)

ho_t1.cpp: In function 'void solve()':
ho_t1.cpp:18:32: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 | #define rep0(i,a) for(int i=0;i<a;i++)
......
   48 |     rep0(i,aa.size()){
      |          ~~~~~~~~~~~            
ho_t1.cpp:48:5: note: in expansion of macro 'rep0'
   48 |     rep0(i,aa.size()){
      |     ^~~~
ho_t1.cpp:54:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |     for(int i=1;i<aa.size();i++){
      |                 ~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...