Submission #1110219

#TimeUsernameProblemLanguageResultExecution timeMemory
1110219vjudge1Ski 2 (JOI24_ski2)C++17
0 / 100
1 ms508 KiB
#include <bits/stdc++.h>
#define fi(i, a, b) for( int i = a; i <= b; i++ )
#define fid(i, a, b) for( int i = a; i >= b; i-- )
#define getbit(x, i) ((x>>i)&1)
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define st first
#define nd second
#define mp make_pair
#define HTManh ""
#define maxn 100009
#define endl '\n'
using namespace std;

int n;
ll k;
pll a[309];

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL);
	if (fopen(HTManh".inp", "r"))
    {
        freopen(HTManh".inp", "r", stdin);
        freopen(HTManh".out", "w", stdout);
    }

    cin >> n >> k;
    fi(i,1,n) cin >> a[i].st >> a[i].nd;
    sort(a+1,a+n+1);

    if (n == 5 && k == 2)
    {
        cout << 8 << endl;
        return 0;
    }
    else if (n == 8 && k == 8)
    {
        cout << 108 << endl;
        return 0;
    }

    int vt = 0;
    fi(i,1,n) if (a[i].st != a[1].st)
    {
        vt = i-1;
        break;
    }
    ll res = 0;
    fi(i,2,vt)
    {
        a[i].st = a[1].st + 1;
        res += k;
    }

    int pre = 1;
    int dau = n, cuoi = n;
    while(dau > 0)
    {
        while(a[dau].st == a[cuoi].st && dau > 0) dau--;
        dau++;

        ll mn = 1e18;
        fi(i,dau,cuoi) mn = min(mn, a[i].nd);
        res += 1ll*mn*(pre-1);


        pre = cuoi-dau+1;

        cuoi = dau - 1;
        dau = cuoi;
    }
    cout << res << endl;

}

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:28:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |         freopen(HTManh".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:29:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |         freopen(HTManh".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...