제출 #781951

#제출 시각아이디문제언어결과실행 시간메모리
781951DymoTeam Contest (JOI22_team)C++14
100 / 100
107 ms17100 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define pll pair<ll,ll> #define ff first #define ss second #define endl "\n" #define pb push_back #define F(i,a,b) for(ll i=a;i<=b;i++) const ll maxn=3e5+10 ; const ll base=3e18; const ll mod= 1e9+7 ; mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); /// have medal in APIO /// goal 2/8 ll n; pair<ll,pll> a[maxn]; set<pll> st; set<pll> st1; ll mx=-1; void add(ll x,ll y) { vector<pll> vt; vt.clear(); auto it=st1.upper_bound(make_pair(x,-base)); while (it!=st1.end()&&(*it).ss<=y) { vt.pb(*it); it++; } for (auto p:vt) st1.erase(p); it=st1.upper_bound(make_pair(x,base)); if (it==st1.begin()) { st1.insert(make_pair(x,y)); } else { it--; if ((*it).ss<y) st1.insert(make_pair(x,y)); } } /* 4 5 6 1 7 5 1 5 5 2 4 7 6 */ int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if (fopen("test.inp","r")) { freopen("test.inp","r",stdin); freopen("test.out","w",stdout); } cin>> n; for (int i=1; i<=n; i++) { cin>> a[i].ff>> a[i].ss.ff>>a[i].ss.ss; } sort(a+1,a+n+1); ll ans=-1; for (int i=1; i<=n; i++) { ll j=i; while (j<=n&&a[j].ff==a[i].ff) j++ ; j--; auto it=st1.upper_bound(make_pair(mx,base)); if (it!=st1.begin()) { it--; ll vals=(*it).ss; for (int t=i;t<=j;t++) { if (a[t].ss.ff<mx&&a[t].ss.ss<vals) { ans=max(ans,mx+vals+a[t].ff); } } } for (int t=i;t<=j;t++) { ll x=a[t].ss.ff; ll y=a[t].ss.ss; add(x+1,y); auto it=st1.upper_bound(make_pair(x,base)); bool chk=false; if (it!=st1.begin()) { it--; if ((*it).ss>y) { chk=true; mx=max(mx,x); } } } i=j; } cout <<ans<<endl; }

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

team.cpp: In function 'int main()':
team.cpp:99:18: warning: variable 'chk' set but not used [-Wunused-but-set-variable]
   99 |             bool chk=false;
      |                  ^~~
team.cpp:64:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   64 |         freopen("test.inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
team.cpp:65:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   65 |         freopen("test.out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...