이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define pi 3.141592653589793238
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define MOD 1000000007
#define INF 999999999999999999
#define pb push_back
#define ff first
#define ss second
#define mt make_tuple
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main() {
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
fast;
ll T = 1, i, j;
//cin >> T;
while (T--) {
ll n;
cin >> n;
vector<pair<ll,ll>> v(n);
for(i = 0; i < n; i++){
cin >> v[i].ff >> v[i].ss;
}
sort(v.begin(), v.end());
ll sum = 0;
ll best = -v[0].ff;
ll ans = -INF;
for(i = 0; i < n; i++){
sum += v[i].ss;
ans = max(ans, sum - v[i].ff - best);
best = min(best, sum - v[i].ss - v[i].ff);
}
cout << ans << endl;
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
art.cpp:4: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
4 | #pragma GCC optimization ("O3")
|
art.cpp:5: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
5 | #pragma GCC optimization ("unroll-loops")
|
art.cpp: In function 'int main()':
art.cpp:29:18: warning: unused variable 'j' [-Wunused-variable]
29 | ll T = 1, i, j;
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |