#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int readInt() {
int x=0;
char ch=getchar_unlocked();
bool s=1;
while(ch<'0'||ch>'9'){if(ch=='-')s=0;ch=getchar_unlocked();}
while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar_unlocked();}
return s?x:-x;
}
constexpr int N = 1e6+5;
pair<int,int> a[N];
int main() {
// ios_base::sync_with_stdio(false);
// cin.tie(0);
int n = readInt();
for(int i = 0; i < n; i++) {
a[i].first = readInt();
a[i].second = readInt();
}
a[n].first = 0;
a[n].second = 0;
sort(a, a+n+1);
long long ans = 0;
for(int i = n - 1; i >= 0; i--) {
a[i].second=max(a[i].second, a[i+1].second);
ans += 1ll*(a[i+1].first-a[i].first)*a[i+1].second;
}
printf("%lld", ans);
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
380 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
288 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
180 ms |
23212 KB |
Output is correct |
2 |
Correct |
179 ms |
23288 KB |
Output is correct |
3 |
Correct |
181 ms |
23160 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
896 KB |
Output is correct |
2 |
Correct |
5 ms |
1024 KB |
Output is correct |
3 |
Correct |
5 ms |
896 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
2688 KB |
Output is correct |
2 |
Correct |
16 ms |
2424 KB |
Output is correct |
3 |
Correct |
16 ms |
2552 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
48 ms |
6776 KB |
Output is correct |
2 |
Correct |
50 ms |
6688 KB |
Output is correct |
3 |
Correct |
50 ms |
6776 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
174 ms |
23160 KB |
Output is correct |
2 |
Correct |
173 ms |
23160 KB |
Output is correct |
3 |
Correct |
175 ms |
23288 KB |
Output is correct |