Submission #789711

#TimeUsernameProblemLanguageResultExecution timeMemory
789711BulaArt Exhibition (JOI18_art)C++17
0 / 100
0 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; }

Compilation message (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: unused variable 'l' [-Wunused-variable]
   22 |  int l = 1,r = n,mx = v[n].first,mn = v[1].first,ans = sum - (mx - mn),c = sum;
      |      ^
art.cpp:22:12: warning: variable 'r' 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...