ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 시험 감독
    백준알고리즘 2019. 7. 17. 21:53
    #include<iostream>
    #include<cstdio>
    
    using namespace std;
    
    int n;
    int a[1000000];
    int b, c;
    
    long long check(long long a, long long c) {
    	long long result = 0;
    	if (a != 0) {
    		if (a % c == 0) {
    			result += (a / c);
    		}
    		else
    			result += (a / c) + 1;
    		return result;
    	}
    	else return 0;
    }
    
    int main() {
    	scanf("%d", &n);
    	for (int i = 0; i < n; i++) {
    		scanf("%d", &a[i]);
    	}
    	scanf("%d %d", &b, &c);
    	long long result = n;
    	for (int i = 0; i < n; i++) {
    		a[i] = a[i] - b;
    		if (a[i] < 0) a[i] = 0;
    	}
    	for (int i = 0; i < n; i++) {
    		result += check(a[i], c);
    	}
    	printf("%lld\n", result);
    	return 0;
    
    }

    데이터 양자체는 크지않은데 데이터 하나하나의 크기가 좀 클거같아서 long long으로 선언하고 진행했다.

    아마, 정답률이 낮은이유는, 데이터 크기에 상관안하고 일반적으로 int로 선언하고 문제를 풀어서 정답률이 낮은듯

    '백준알고리즘' 카테고리의 다른 글

    영역 구하기  (0) 2019.07.17
    보물섬  (0) 2019.07.17
    유기농 배추  (0) 2019.07.17
    연구소  (0) 2019.07.17
    기지국  (0) 2019.07.14

    댓글

Designed by Tistory.