답안 #654063

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
654063 2022-10-29T17:38:18 Z nolimiya Stove (JOI18_stove) C++14
100 / 100
46 ms 38092 KB
#include <bits/stdc++.h>
#include <math.h>
//in the name of god,aka allah
//**gray sety orz**
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("unroll-loops")
using namespace std;
#define pi pair<long long , long long>
#define pii pair<long long , pair<long long , long long>>
const int maxm = 5e5;
const long long mod = 1e9 + 7 ;
typedef long long ll;
ll l,r,mid;
ll n,m;
ll dis[maxm] , sum[maxm];
bool isval(int mid){
    //cout << mid <<" " << mid*mid-mid <<endl;
    if (((mid-1)*mid)/2 < m) return 0;
    return 1;
}
ll darage[maxm] , ss , mm;
queue<int> q;
vector<ll> g[maxm] , z[maxm];
ll sath[maxm];
bool vis[maxm] , gos[maxm];
ll pedaret[maxm];
ll get_par(ll v){
    if (pedaret[v]==v) return v;
    return pedaret[v] = get_par(pedaret[v]);
}
void merge(ll r , ll q){
    if (get_par(r)!=get_par(q))l+=max(darage[r],darage[q])*1ll*sath[r]*1ll*sath[q];
    r = get_par(r) , q = get_par(q);
    if (r!=q){
        if (sath[r]<sath[q]) swap(r,q);
        pedaret[q] = r;
        sath[r] += sath[q];
    }
    return ;
}
ll pars1[maxm] , pars2[maxm];
vector<ll> se[maxm];
set<int> st;
ll rp[maxm];
pi w[maxm];
ll dp[maxm];
//ll rw[maxm][maxm];
map<ll,ll> mp;
int main(){
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin >>n>>m;
    for (int i=0; i<n; i++){
        cin>>pedaret[i];
    }
    sort(pedaret,pedaret+n);
    for (int i=0; i<n-1; i++){
        darage[i] = pedaret[i+1]-pedaret[i]-1;
    }
    sort(darage,darage+n-1);
    for (int i=0; i<n-m; i++) mid+=darage[i];
    cout<<mid+n;
}

Compilation message

stove.cpp:5: warning: ignoring '#pragma comment ' [-Wunknown-pragmas]
    5 | #pragma comment(linker, "/stack:200000000")
      |
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 35540 KB Output is correct
2 Correct 19 ms 35540 KB Output is correct
3 Correct 19 ms 35580 KB Output is correct
4 Correct 19 ms 35576 KB Output is correct
5 Correct 18 ms 35456 KB Output is correct
6 Correct 18 ms 35484 KB Output is correct
7 Correct 20 ms 35540 KB Output is correct
8 Correct 23 ms 35564 KB Output is correct
9 Correct 19 ms 35540 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 35540 KB Output is correct
2 Correct 19 ms 35540 KB Output is correct
3 Correct 19 ms 35580 KB Output is correct
4 Correct 19 ms 35576 KB Output is correct
5 Correct 18 ms 35456 KB Output is correct
6 Correct 18 ms 35484 KB Output is correct
7 Correct 20 ms 35540 KB Output is correct
8 Correct 23 ms 35564 KB Output is correct
9 Correct 19 ms 35540 KB Output is correct
10 Correct 20 ms 35556 KB Output is correct
11 Correct 18 ms 35628 KB Output is correct
12 Correct 21 ms 35636 KB Output is correct
13 Correct 18 ms 35620 KB Output is correct
14 Correct 21 ms 35624 KB Output is correct
15 Correct 20 ms 35580 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 35540 KB Output is correct
2 Correct 19 ms 35540 KB Output is correct
3 Correct 19 ms 35580 KB Output is correct
4 Correct 19 ms 35576 KB Output is correct
5 Correct 18 ms 35456 KB Output is correct
6 Correct 18 ms 35484 KB Output is correct
7 Correct 20 ms 35540 KB Output is correct
8 Correct 23 ms 35564 KB Output is correct
9 Correct 19 ms 35540 KB Output is correct
10 Correct 20 ms 35556 KB Output is correct
11 Correct 18 ms 35628 KB Output is correct
12 Correct 21 ms 35636 KB Output is correct
13 Correct 18 ms 35620 KB Output is correct
14 Correct 21 ms 35624 KB Output is correct
15 Correct 20 ms 35580 KB Output is correct
16 Correct 38 ms 38088 KB Output is correct
17 Correct 45 ms 38008 KB Output is correct
18 Correct 46 ms 38012 KB Output is correct
19 Correct 40 ms 38012 KB Output is correct
20 Correct 37 ms 38076 KB Output is correct
21 Correct 41 ms 37972 KB Output is correct
22 Correct 37 ms 38000 KB Output is correct
23 Correct 37 ms 38092 KB Output is correct
24 Correct 39 ms 38008 KB Output is correct