Submission #772404

#TimeUsernameProblemLanguageResultExecution timeMemory
772404RecursiveCoArt Exhibition (JOI18_art)C++14
100 / 100
181 ms28832 KiB
// CF template, version 3.0 #include <bits/stdc++.h> using namespace std; #define improvePerformance ios_base::sync_with_stdio(false); cin.tie(0) #define getTest int t; cin >> t #define eachTest for (int _var=0;_var<t;_var++) #define get(name) int (name); cin >> (name) #define out(o) cout << (o) #define getList(cnt, name) vector<int> (name); for (int _=0;_<(cnt);_++) { get(a); (name).push_back(a); } #define sortl(name) sort((name).begin(), (name).end()) #define rev(name) reverse((name).begin(), (name).end()) #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++) #define decision(b) if (b){out("YES");}else{out("NO");} #define int long long int signed main() { improvePerformance; get(n); vector<pair<int, int>> art; forto(n, i) { get(a); get(b); art.push_back({a, b}); } sortl(art); vector<int> values; forto(n, i) values.push_back(art[i].first + art[i].second - (i == n - 1? 0: art[i + 1].first)); int maxsub = values[0]; int ans = art[0].second; for (int i = 1; i < n; i++) { maxsub = max(0ll, maxsub) + values[i]; ans = max(ans, maxsub - art[i].first + (i == n - 1? 0: art[i + 1].first)); } out(ans); }

Compilation message (stderr)

art.cpp: In function 'int main()':
art.cpp:10:23: warning: unnecessary parentheses in declaration of 'n' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
art.cpp:22:5: note: in expansion of macro 'get'
   22 |     get(n);
      |     ^~~
art.cpp:15:35: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   15 | #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
      |                                   ^
art.cpp:24:5: note: in expansion of macro 'forto'
   24 |     forto(n, i) {
      |     ^~~~~
art.cpp:10:23: warning: unnecessary parentheses in declaration of 'a' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
art.cpp:25:9: note: in expansion of macro 'get'
   25 |         get(a);
      |         ^~~
art.cpp:10:23: warning: unnecessary parentheses in declaration of 'b' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
art.cpp:26:9: note: in expansion of macro 'get'
   26 |         get(b);
      |         ^~~
art.cpp:15:35: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   15 | #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
      |                                   ^
art.cpp:31:5: note: in expansion of macro 'forto'
   31 |     forto(n, i) values.push_back(art[i].first + art[i].second - (i == n - 1? 0: art[i + 1].first));
      |     ^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...