제출 #492825

#제출 시각아이디문제언어결과실행 시간메모리
492825KarabasanArt Exhibition (JOI18_art)C++17
0 / 100
1 ms332 KiB
#include <bits/stdc++.h> #define ll long long #define fast1 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define endl "\n" #define int long long using namespace std; #pragma GCC optimize("Ofast") #pragma GCC target("fma,sse,sse2,sse3,avx") #pragma GCC optimize("unroll-loops") int n; pair<int,int> p[500005]; int pre[500005]; void solve() { cin>>n; for(int i=1;i<=n;i++) cin>>p[i].first>>p[i].second; sort(p+1,p+n+1); pre[1]=p[1].second; for(int i=2;i<=n;i++) pre[i]=pre[i-1]+p[i].second; int mn=p[1].first; int mx=p[1].first; int val=p[1].second; int cvp=p[1].second; int ind=1; for(int i=2;i<=n;i++) { while(p[i].first-mn>pre[i]-pre[ind-1]&&ind<i) { mn=p[ind+1].first; ind++; } cvp=max(cvp,pre[i]-pre[ind-1]-p[i].first+mn); } cout<<cvp; } signed main() { fast1 //freopen ("lca.gir","r",stdin); //freopen ("lca.cik","w",stdout); int t=1; //cin>>t; while(t--) { solve(); } return 0; }

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

art.cpp: In function 'void solve()':
art.cpp:24:9: warning: unused variable 'mx' [-Wunused-variable]
   24 |     int mx=p[1].first;
      |         ^~
art.cpp:25:9: warning: unused variable 'val' [-Wunused-variable]
   25 |     int val=p[1].second;
      |         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...