답안 #67609

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
67609 2018-08-15T06:05:52 Z imsifile 코코넛 젤리 음료수 (FXCUP3_nectar) C++
100 / 100
626 ms 1452 KB
#include<stdio.h>
#include<vector>
using namespace std;

typedef long long lld;

struct rle {
	int a, rpt;
	rle(int a_=0, int rpt_=0) : a(a_), rpt(rpt_) {}
};

int N, J, R, T, rcn;
vector<rle> v[2];
lld sum;

int ce(int a){ return (a+R-1)/R; }
void push(int ix, rle k){
	if(k.rpt == 0) return;
	if(v[ix].empty()){ v[ix].push_back(k); return; }
	int last=v[ix].size()-1;
	if(v[ix][last].a == k.a) v[ix][last].rpt += k.rpt;
	else v[ix].push_back(k);
}

int main(){
	scanf("%d%d%d%d", &N, &J, &R, &T);
	if(N==1){ printf("%d\n", J); return 0; }
	push(0, rle(J, N-1)), sum=J;
	int cur=0;
	for(int i=T; i--;){
		sum += ce(v[cur][0].a);
		for(int j=0; j<v[cur].size(); j++){
			rle r = v[cur][j]; int com = 0;
			if(j<v[cur].size()-1) com=v[cur][j+1].a;
			push(cur^1, rle(r.a, r.rpt-1));
			push(cur^1, rle(r.a-ce(r.a)+ce(com), 1));
		}
		v[cur].clear(); cur^=1;
	}
	for(int i=v[cur].size(); i--;){
		for(int j=v[cur][i].rpt; j--;) printf("%d\n", v[cur][i].a);
	}
	printf("%lld\n", sum);
	return 0;
}

Compilation message

nectar.cpp: In function 'int main()':
nectar.cpp:32:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=0; j<v[cur].size(); j++){
                ~^~~~~~~~~~~~~~
nectar.cpp:34:8: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if(j<v[cur].size()-1) com=v[cur][j+1].a;
       ~^~~~~~~~~~~~~~~~
nectar.cpp:26:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d%d", &N, &J, &R, &T);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 248 KB Output is correct
2 Correct 3 ms 356 KB Output is correct
3 Correct 2 ms 560 KB Output is correct
4 Correct 3 ms 560 KB Output is correct
5 Correct 2 ms 560 KB Output is correct
6 Correct 2 ms 560 KB Output is correct
7 Correct 3 ms 560 KB Output is correct
8 Correct 6 ms 560 KB Output is correct
9 Correct 2 ms 560 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 248 KB Output is correct
2 Correct 3 ms 356 KB Output is correct
3 Correct 2 ms 560 KB Output is correct
4 Correct 3 ms 560 KB Output is correct
5 Correct 2 ms 560 KB Output is correct
6 Correct 2 ms 560 KB Output is correct
7 Correct 3 ms 560 KB Output is correct
8 Correct 6 ms 560 KB Output is correct
9 Correct 2 ms 560 KB Output is correct
10 Correct 24 ms 588 KB Output is correct
11 Correct 23 ms 904 KB Output is correct
12 Correct 59 ms 920 KB Output is correct
13 Correct 109 ms 1304 KB Output is correct
14 Correct 16 ms 1304 KB Output is correct
15 Correct 16 ms 1304 KB Output is correct
16 Correct 24 ms 1304 KB Output is correct
17 Correct 626 ms 1304 KB Output is correct
18 Correct 187 ms 1324 KB Output is correct
19 Correct 66 ms 1452 KB Output is correct
20 Correct 62 ms 1452 KB Output is correct
21 Correct 16 ms 1452 KB Output is correct
22 Correct 52 ms 1452 KB Output is correct
23 Correct 35 ms 1452 KB Output is correct