제출 #4175

#제출 시각아이디문제언어결과실행 시간메모리
4175pl0892029King of penalty (kriii1_K)C++98
컴파일 에러
0 ms0 KiB
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>

using namespace std;

void main() {
	int p, t, t1;
	int *pt;
	int i, num;
	long long penalty=0, tmp=0, wait; 
	scanf("%d %d", &t, &p);

	pt = (int *)malloc(sizeof(int)*p);
	for(i=0;i<p;i++)
		scanf("%d", &pt[i]);
	
	sort(pt,pt+p);
	i=0;
	t1 = t;
	while(true) {
		t1-=pt[i];
		if(t1<=0 || i==p)
			break;
		penalty+=pt[i];
		i++;
	}
	num=i;
	wait = t-penalty-1;
	for(i=num-1;i>=0;i--) {
		wait+=pt[i];
		tmp+=wait;
	}
	free(pt);
	printf("%d %lld\n", num, tmp); 
}

컴파일 시 표준 에러 (stderr) 메시지

K.cpp:7:11: error: '::main' must return 'int'
K.cpp: In function 'int main()':
K.cpp:12:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
K.cpp:16:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]