# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
298736 |
2020-09-13T22:14:31 Z |
brkdnmz |
Unija (COCI17_unija) |
C++17 |
|
370 ms |
54660 KB |
#include <iostream>
#include <fstream>
#include <cstdio>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <string.h>
#include <string>
#include <math.h>
#include <iomanip>
#include <cassert>
#include <random>
using namespace std;
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define pb push_back
#define FOR(i, n) for(int i = 0; i < (n); i++)
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
const int mod = 1e9 + 7;
const int mod2 = 998244353;
void fact_init(int n);
ll exp(ll taban, ll us, ll md);
ll ebob(ll a, ll b);
ll ekok(ll a, ll b);
ll komb(ll a, ll b);
vector<ll> fact;
vector<ll> inv_fact;
void fact_init(int n){
fact.resize(n+5);
inv_fact.resize(n+5);
fact[0] = inv_fact[0] = 1;
for(int i = 1; i <= n; i++){
fact[i] = (fact[i-1] * i) % mod;
inv_fact[i] = exp(fact[i], mod-2, mod);
}
}
ll exp(ll taban, ll us, ll md) {
ll carpan = taban % md;
if(carpan == 0) return 0;
ll temp = us;
ll res = 1;
while(temp){
if(temp % 2) res = (res*carpan) % md;
temp /= 2;
carpan = (carpan*carpan) % md;
}
return res;
}
ll ebob(ll a, ll b){
if(!a)return b;
return ebob(b%a, a);
}
ll ekok(ll a, ll b){
return (a*b)/ebob(a, b);
}
ll komb(ll a, ll b){
if(a < b) return 0;
return fact[a] * (inv_fact[a-b] * inv_fact[b] % mod) % mod;
}
const int N = 1e7 + 5;
int main(){
ios::sync_with_stdio(false); cin.tie(NULL);
int n; cin>>n;
vector<int> cnt(N, 0);
while(n--){
int x, y; cin>>x>>y;
x /= 2;
cnt[x] = max(cnt[x], y);
}
ll res = 0;
for(int i = N-1; i >= 1; i--){
if(i < N-1) cnt[i] = max(cnt[i], cnt[i+1]);
res += cnt[i];
}
res *= 2;
cout<<res<<"\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
63 ms |
39416 KB |
Output is correct |
2 |
Correct |
63 ms |
39424 KB |
Output is correct |
3 |
Correct |
64 ms |
39424 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
63 ms |
39424 KB |
Output is correct |
2 |
Correct |
63 ms |
39416 KB |
Output is correct |
3 |
Correct |
65 ms |
39424 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
65 ms |
39552 KB |
Output is correct |
2 |
Correct |
63 ms |
39424 KB |
Output is correct |
3 |
Correct |
63 ms |
39552 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
64 ms |
39552 KB |
Output is correct |
2 |
Correct |
66 ms |
39552 KB |
Output is correct |
3 |
Correct |
65 ms |
39552 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
349 ms |
54520 KB |
Output is correct |
2 |
Correct |
356 ms |
54660 KB |
Output is correct |
3 |
Correct |
370 ms |
54520 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
63 ms |
39424 KB |
Output is correct |
2 |
Correct |
63 ms |
39416 KB |
Output is correct |
3 |
Correct |
64 ms |
39424 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
70 ms |
39936 KB |
Output is correct |
2 |
Correct |
69 ms |
39800 KB |
Output is correct |
3 |
Correct |
69 ms |
39800 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
85 ms |
40824 KB |
Output is correct |
2 |
Correct |
87 ms |
40824 KB |
Output is correct |
3 |
Correct |
85 ms |
40960 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
129 ms |
43512 KB |
Output is correct |
2 |
Correct |
125 ms |
43512 KB |
Output is correct |
3 |
Correct |
128 ms |
43512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
341 ms |
54520 KB |
Output is correct |
2 |
Correct |
351 ms |
54648 KB |
Output is correct |
3 |
Correct |
341 ms |
54520 KB |
Output is correct |