Submission #26023

# Submission time Handle Problem Language Result Execution time Memory
26023 2017-06-26T14:33:44 Z iletavcioski Unija (COCI17_unija) C++14
100 / 100
426 ms 26796 KB
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<iomanip>
using namespace std;
typedef  long long ll;
int main()
{
    ios_base::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<pair<ll,ll> >v;
    for(int i=0;i<n;i++)
    {
        ll a,b;
        cin>>a>>b;
        b/=2;
        v.push_back(make_pair(a,b));
    }
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    int i=0;
    ll maxi=0;
    ll prethoden=0;
    ll brojac=0;
    while(i<n)
    {
        if(v[i].second>maxi)
        {
            brojac+=((v[i].second-maxi)*v[i].first);
            maxi=v[i].second;
                
        }
        i++;
    }
    brojac*=2;
    cout<<brojac<<endl;
    return 0;
}

Compilation message

unija.cpp: In function 'int main()':
unija.cpp:25:8: warning: unused variable 'prethoden' [-Wunused-variable]
     ll prethoden=0;
        ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2180 KB Output is correct
2 Correct 0 ms 2180 KB Output is correct
3 Correct 0 ms 2180 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2180 KB Output is correct
2 Correct 0 ms 2180 KB Output is correct
3 Correct 0 ms 2180 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2180 KB Output is correct
2 Correct 0 ms 2180 KB Output is correct
3 Correct 0 ms 2180 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2340 KB Output is correct
2 Correct 3 ms 2340 KB Output is correct
3 Correct 0 ms 2340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 393 ms 26796 KB Output is correct
2 Correct 339 ms 26796 KB Output is correct
3 Correct 426 ms 26796 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2180 KB Output is correct
2 Correct 0 ms 2180 KB Output is correct
3 Correct 0 ms 2180 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 2988 KB Output is correct
2 Correct 9 ms 2988 KB Output is correct
3 Correct 6 ms 2988 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 36 ms 5292 KB Output is correct
2 Correct 36 ms 5292 KB Output is correct
3 Correct 26 ms 5292 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 109 ms 14508 KB Output is correct
2 Correct 106 ms 14508 KB Output is correct
3 Correct 99 ms 14508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 396 ms 26796 KB Output is correct
2 Correct 346 ms 26796 KB Output is correct
3 Correct 359 ms 26796 KB Output is correct