답안 #4346

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
4346 2013-09-17T10:07:57 Z zorrapower King of penalty (kriii1_K) C++
1 / 1
28 ms 1868 KB
#include<stdio.h>
#include <algorithm>

using namespace std;

#define MAX_NUMBER 100000
long long SolveTime[MAX_NUMBER];


int main(void){
	long long P;
	long long N;
	long long Possible;
	long long PAT=0;
	long long START_TIME;

	scanf("%lld %lld", &P, &N);
	for(int i=0; i<N; i++){
		scanf("%lld", &SolveTime[i]);
	}

	sort(SolveTime,SolveTime+N);
	
	long long SUM=0;
	for(int i=0; i<N; i++){
		SUM+=SolveTime[i];
		Possible=i;
		if(SUM>=P){
			i--;
			break;
		}
	}
	if(SUM<=P)
		Possible++;

	printf("%lld\n", Possible);

	START_TIME=P;
	for(int i=0; i<Possible; i++){
		START_TIME-=SolveTime[i];
	}
	START_TIME--;

	PAT+=START_TIME*Possible;
	for(int i=0; i<Possible; i++){
		PAT+=SolveTime[i]*(i+1);
	}

	printf("%lld\n", PAT);
	scanf("%*d");
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1868 KB Output is correct
2 Correct 0 ms 1868 KB Output is correct
3 Correct 0 ms 1868 KB Output is correct
4 Correct 4 ms 1868 KB Output is correct
5 Correct 0 ms 1868 KB Output is correct
6 Correct 4 ms 1868 KB Output is correct
7 Correct 8 ms 1868 KB Output is correct
8 Correct 8 ms 1868 KB Output is correct
9 Correct 28 ms 1868 KB Output is correct
10 Correct 24 ms 1868 KB Output is correct
11 Correct 16 ms 1868 KB Output is correct
12 Correct 12 ms 1868 KB Output is correct
13 Correct 0 ms 1868 KB Output is correct
14 Correct 0 ms 1868 KB Output is correct
15 Correct 8 ms 1868 KB Output is correct