Submission #1278132

#TimeUsernameProblemLanguageResultExecution timeMemory
1278132phuocrucppArt Exhibition (JOI18_art)C++20
100 / 100
151 ms12104 KiB
/*ㅤ∧_∧  ( ・∀・)  ( つ┳⊃ ε (_)へ⌒ヽフ (  ( ・ω・) ◎―◎ ⊃ ⊃ BePhuongSuperSuwi From TK4 - CHT ㅤㅤ/ ⌒\____   /・   )  \  /ノへ ノ    /| ノ   \\ |/_/_/*/ #include<bits/stdc++.h> #define task "main" //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> #define endl '\n' #define int long long #define pb push_back #define fi first #define se second #define ii pair<int,int> #define iii pair<int,ii> #define iv pair<ii, ii> #define base 341 #define MASK(i) (1ll << i) #define oo 1e18 #define isOn(x,i) ((x) & MASK(i)) #define bitOn(x,i) ((x) | MASK(i)) #define bitOff(x,i) ((x) & ~MASK(i)) #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> #define __lcm(a,b) (1ll * ((a) / __gcd((a), (b))) * (b)) using namespace std; //using namespace __gnu_pbds; const int maxn = 1e6 + 5; int n, sum[maxn]; ii a[maxn]; main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); if(fopen(task".inp","r")) { freopen(task".inp","r",stdin); freopen(task".out","w",stdout); } cin >> n; for (int i = 1; i <= n; i++) cin >> a[i].fi >> a[i].se; sort(a + 1, a + n + 1); int mini = 0, maxi = -oo; for (int i = 1; i <= n; i++) { sum[i] = sum[i - 1] + a[i].se; mini = min(mini, sum[i - 1] - a[i].fi); maxi = max(maxi, sum[i] - a[i].fi - mini); } cout << maxi; }

Compilation message (stderr)

art.cpp:40:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   40 | main() {
      | ^~~~
art.cpp: In function 'int main()':
art.cpp:43:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 |         freopen(task".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
art.cpp:44:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   44 |         freopen(task".out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...