이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define MOEZ ios_base::sync_with_stdio(false);cin.tie(NULL),cout.tie(NULL);
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define F first
#define S second
#define pb push_back
#define all(v) v.begin() , v.end()
#define eb emplace_back
#define getunique(v) {sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end());}
#define mem(d , x) memset(d , x , sizeof(d));
#define sz(x) (int)x.size()
//const int N = 2e5+5;
//const int M = 1e9+7;
//const ll inf = 1e17;
//const ld eps = 1e-6;
#define int long long
int n , s = 0;
//multiset<pair<int , int>>m;
signed main(){
MOEZ
cin >> n;
map<int , int>mp;
for(int i = 0; i < n;i++){
int a , b;
cin >> a >> b;
mp[a] += b;
}
vector<pair<int , int>>v;
int i = 0;
for(auto x:mp){
v.pb(x);
if(i){
v[i].S += v[i-1].S;
}
i++;
}
int ans = v[0].S, l = 0;
for(i = 0; i < n;i++){
int x = 0;
if(i)x = v[i-1].S;
for(int j = i; j < n;j++){
ans = max(ans , (v[j].S-x)-(v[j].F-v[i].F));
}
}
cout << ans;
}
컴파일 시 표준 에러 (stderr) 메시지
art.cpp: In function 'int main()':
art.cpp:44:23: warning: unused variable 'l' [-Wunused-variable]
44 | int ans = v[0].S, l = 0;
| ^
# | 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... |