Submission #1228954

#TimeUsernameProblemLanguageResultExecution timeMemory
1228954nvt2k9Art Exhibition (JOI18_art)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 5e5 + 5;
int n;
pair<int,int> a[N];
int pre[N];
signed main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  cin >> n;
  for(int i = 1; i <= n; i++) cin >> a[i].first >> a[i].second;
  sort(a + 1, a + n + 1);
  for(int i = 1; i <= n; i++){
    pre[i]=pre[i-1]+ a[i].second;
  }
  int gm = 0, res = 0;
  // S = 
  for(int i = 1; i <= n; i++){
    amin= max(gm, a[i].first - pre[i-1]);
    res = max(res, pre[i] - a[i].first + amin);
  }
  cout << res << "\n";
}

Compilation message (stderr)

art.cpp: In function 'int main()':
art.cpp:20:5: error: 'amin' was not declared in this scope; did you mean 'main'?
   20 |     amin= max(gm, a[i].first - pre[i-1]);
      |     ^~~~
      |     main