Submission #1837335


Source Code Expand

#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

#define int long long

signed main(){
	int n, k;
	cin >> n >> k;

	vector<int> v(n);
	rep(i,n){
		cin >> v[i];
	}

	sort(all(v));
	int cur = 0;
	int sum = 0;
	rep(i,k){
		sum += v[i] + cur;
		cur++;
	}
	cout << sum << endl;
	return 0;

	cout << accumulate(v.begin(), next(v.begin(), k), 0) + (k - 1) * k / 2 << endl;
}

Submission Info

Submission Time
Task B - オークション
User noy72
Language C++14 (GCC 5.4.1)
Score 200
Code Size 608 Byte
Status AC
Exec Time 54 ms
Memory 1152 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 2
AC × 17
Set Name Test Cases
Sample sample1.txt, sample2.txt
All sample1.txt, sample2.txt, in1.txt, in10.txt, in11.txt, in12.txt, in13.txt, in2.txt, in3.txt, in4.txt, in5.txt, in6.txt, in7.txt, in8.txt, in9.txt, sample1.txt, sample2.txt
Case Name Status Exec Time Memory
in1.txt AC 47 ms 1152 KB
in10.txt AC 47 ms 1024 KB
in11.txt AC 47 ms 1024 KB
in12.txt AC 47 ms 1024 KB
in13.txt AC 1 ms 256 KB
in2.txt AC 47 ms 1024 KB
in3.txt AC 47 ms 1024 KB
in4.txt AC 47 ms 1024 KB
in5.txt AC 47 ms 1024 KB
in6.txt AC 54 ms 1024 KB
in7.txt AC 47 ms 1024 KB
in8.txt AC 47 ms 1024 KB
in9.txt AC 47 ms 1024 KB
sample1.txt AC 1 ms 256 KB
sample2.txt AC 1 ms 256 KB