제출 #765089

#제출 시각아이디문제언어결과실행 시간메모리
765089KryzArt Exhibition (JOI18_art)C++17
0 / 100
1 ms340 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define fi first #define se second #define sst string #define pb push_back #define maxco 100000+5 #define lld long double #define cha ios_base::sync_with_stdio(false); #define ffl cout.flush(); #define phi acos(-1) #define mod 707 #define mr make_pair #define pqin priority_queue<ll,vector<ll>,greater<>> #define pqpair priority_queue<pair<ll,ll> ,vector<pair<ll,ll>>,greater<pair<ll,ll>>> #define pqpair2 priority_queue<pair<pair<ll,ll>,pair<ll,ll>>,vector<pair<pi,pair<ll,ll>>>,greater<pair<pi,pair<ll,ll>>>> #define INF 1000000009 #define MAXN 500069 #define pi pair<ll,ll> ll mvx[]={1,-1,0,0}; ll mvy[]={0,0,1,-1}; pair<ll,ll> pr[MAXN]; ll ps[MAXN]; int main(){ ll n; cin>>n; set<ll> st; for(ll i=1;i<=n;i++){ cin>>pr[i].fi>>pr[i].se; } sort(pr+1,pr+n+1); ll mk=0; ll idx; for(ll i=1;i<=n;i++){ ps[i]+=ps[i-1]+pr[i].se; if(ps[i]-pr[i].fi>mk){ mk=ps[i]-pr[i].fi; idx=i; } } ll ans=0; for(ll i=1;i<=idx;i++){ ans=max(ans,pr[i].fi+ps[idx]-ps[i-1]-pr[idx].fi); } for(ll i=1;i<=n;i++){ ans=max(ans,pr[i].se-pr[i].fi); } cout<<ans<<endl; }

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

art.cpp: In function 'int main()':
art.cpp:44:17: warning: 'idx' may be used uninitialized in this function [-Wmaybe-uninitialized]
   44 |     for(ll i=1;i<=idx;i++){
      |                ~^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...