제출 #789709

#제출 시각아이디문제언어결과실행 시간메모리
789709BulaArt Exhibition (JOI18_art)C++17
0 / 100
1 ms212 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() #define int ll const ll mod=1e9+7; main(){ int n; cin>>n; vector< pair<int,int> > v(n+1); int sum = 0; for(int i=1;i<=n;i++){ cin>>v[i].first>>v[i].second; sum += v[i].second; } sort(all(v)); int l = 1,r = n,mx = v[n].first,mn = v[1].first,ans = sum - (mx - mn),c = sum; //cout << ans << endl; for(int i=n;i>=1;i--){ int cur = c - (v[i].first - mn); if(cur >= ans){ ans = cur; r = i; } c -= v[i].second; } //cout << ans << endl; for(int i=1;i<=r;i++){ int cur = c - (v[r].first - v[i].first); if(cur >= ans){ ans = cur; l = i; } c -= v[i].second; } cout << ans << endl; }

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

art.cpp:11:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   11 | main(){
      | ^~~~
art.cpp: In function 'int main()':
art.cpp:22:6: warning: variable 'l' set but not used [-Wunused-but-set-variable]
   22 |  int l = 1,r = n,mx = v[n].first,mn = v[1].first,ans = sum - (mx - mn),c = sum;
      |      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...