Submission #44720468


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pk pop_back
#define fr first
#define sc second
#define endl '\n'
#define upb upper_bound
#define lob lower_bound
const ll mod = 1000000007, mod2 = 998244353;
const ll INF = INT_MAX, INF2 = LLONG_MAX-1;
int n;
pair<ll, ll> a[300005];
void solve(){
cin >> n;
for (ll i = 0; i < n; ++i){
cin >> a[i].sc >> a[i].fr;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pk pop_back
#define fr first
#define sc second
#define endl '\n'
#define upb upper_bound
#define lob lower_bound

const ll mod = 1000000007, mod2 = 998244353;
const ll INF = INT_MAX, INF2 = LLONG_MAX-1;

int n;
pair<ll, ll> a[300005];

void solve(){
    cin >> n;
    for (ll i = 0; i < n; ++i){
        cin >> a[i].sc >> a[i].fr;
    }
    sort(a, a+n);
    ll ans = 0;
    for (ll i = n-2; i >= 0; --i){
        if(a[i].sc == a[n-1].sc) ans = max(ans, a[i].fr/2 + a[n-1].fr);
        else ans = max(ans, a[i].fr + a[n-1].fr);
    }
    cout << ans;
}

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int tt = 1; 
    while(tt--){
        solve(); 
        cout << endl;
    }
    return 0;
}

Submission Info

Submission Time
Task C - Flavors
User picramide
Language C++ 20 (gcc 12.2)
Score 300
Code Size 850 Byte
Status AC
Exec Time 57 ms
Memory 8296 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 2
AC × 51
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
All killer_01.txt, killer_02.txt, killer_03.txt, sample_01.txt, sample_02.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt, test_25.txt, test_26.txt, test_27.txt, test_28.txt, test_29.txt, test_30.txt, test_31.txt, test_32.txt, test_33.txt, test_34.txt, test_35.txt, test_36.txt, test_37.txt, test_38.txt, test_39.txt, test_40.txt, test_41.txt, test_42.txt, test_43.txt, test_44.txt, test_45.txt, test_46.txt
Case Name Status Exec Time Memory
killer_01.txt AC 32 ms 8212 KB
killer_02.txt AC 35 ms 8116 KB
killer_03.txt AC 38 ms 8100 KB
sample_01.txt AC 1 ms 3472 KB
sample_02.txt AC 1 ms 3472 KB
test_01.txt AC 1 ms 3528 KB
test_02.txt AC 1 ms 3412 KB
test_03.txt AC 1 ms 3476 KB
test_04.txt AC 1 ms 3336 KB
test_05.txt AC 36 ms 8088 KB
test_06.txt AC 34 ms 8156 KB
test_07.txt AC 21 ms 5296 KB
test_08.txt AC 37 ms 6652 KB
test_09.txt AC 2 ms 3408 KB
test_10.txt AC 24 ms 5612 KB
test_11.txt AC 34 ms 6364 KB
test_12.txt AC 12 ms 4572 KB
test_13.txt AC 25 ms 5568 KB
test_14.txt AC 18 ms 5060 KB
test_15.txt AC 27 ms 5856 KB
test_16.txt AC 49 ms 7512 KB
test_17.txt AC 9 ms 4240 KB
test_18.txt AC 32 ms 6308 KB
test_19.txt AC 7 ms 4100 KB
test_20.txt AC 30 ms 6256 KB
test_21.txt AC 29 ms 6060 KB
test_22.txt AC 16 ms 4752 KB
test_23.txt AC 48 ms 7548 KB
test_24.txt AC 19 ms 5096 KB
test_25.txt AC 23 ms 5300 KB
test_26.txt AC 6 ms 4040 KB
test_27.txt AC 54 ms 8148 KB
test_28.txt AC 54 ms 8292 KB
test_29.txt AC 54 ms 8080 KB
test_30.txt AC 53 ms 8164 KB
test_31.txt AC 57 ms 8100 KB
test_32.txt AC 54 ms 8152 KB
test_33.txt AC 53 ms 8108 KB
test_34.txt AC 54 ms 8160 KB
test_35.txt AC 53 ms 8152 KB
test_36.txt AC 54 ms 8100 KB
test_37.txt AC 54 ms 8092 KB
test_38.txt AC 55 ms 8288 KB
test_39.txt AC 56 ms 8112 KB
test_40.txt AC 52 ms 8216 KB
test_41.txt AC 55 ms 8080 KB
test_42.txt AC 55 ms 8020 KB
test_43.txt AC 55 ms 8296 KB
test_44.txt AC 55 ms 8160 KB
test_45.txt AC 55 ms 8140 KB
test_46.txt AC 55 ms 8152 KB


2025-03-05 (Wed)
20:38:44 +00:00