# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
633591 |
2022-08-22T19:12:01 Z |
inksamurai |
Unija (COCI17_unija) |
C++17 |
|
318 ms |
47508 KB |
#include <bits/stdc++.h>
#define int ll
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rng(i,c,n) for(int i=c;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)a.size()
#define vec(...) vector<__VA_ARGS__>
#define _3PGDklf ios::sync_with_stdio(0),cin.tie(0)
typedef long long ll;
using pii=pair<int,int>;
using vi=vector<int>;
void print(){cout<<'\n';}
template<class h,class...t>
void print(const h&v,const t&...u){cout<<v<<' ',print(u...);}
// e
signed main(){
_3PGDklf;
int n;
cin>>n;
vec(pii) a(n);
rep(i,n){
cin>>a[i].fi>>a[i].se;
a[i].fi/=2;
a[i].se/=2;
}
sort(a.begin(), a.end());
int sun=0;
vec(pii) stk;
stk.pb(pii(0,0));
rep(i,n){
pii p=a[i];
if(!sz(stk)){
stk.pb(p);
sun+=p.fi*p.se;
}else{
while(sz(stk)>1){
pii np=stk.back();
if(np.se>p.se){
break;
}else{
stk.pop_back();
sun-=(np.fi-stk.back().fi)*np.se;
}
}
sun+=(p.fi-stk.back().fi)*p.se;
stk.pb(p);
}
}
print(sun*4);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
468 KB |
Output is correct |
2 |
Correct |
2 ms |
468 KB |
Output is correct |
3 |
Correct |
2 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
318 ms |
47456 KB |
Output is correct |
2 |
Correct |
300 ms |
47476 KB |
Output is correct |
3 |
Correct |
294 ms |
47508 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
1108 KB |
Output is correct |
2 |
Correct |
7 ms |
1048 KB |
Output is correct |
3 |
Correct |
7 ms |
1048 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
3208 KB |
Output is correct |
2 |
Correct |
26 ms |
3156 KB |
Output is correct |
3 |
Correct |
32 ms |
3280 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
90 ms |
8976 KB |
Output is correct |
2 |
Correct |
76 ms |
8976 KB |
Output is correct |
3 |
Correct |
77 ms |
8972 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
288 ms |
30980 KB |
Output is correct |
2 |
Correct |
279 ms |
30984 KB |
Output is correct |
3 |
Correct |
311 ms |
30980 KB |
Output is correct |