답안 #67617

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
67617 2018-08-15T06:43:53 Z imsifile 코코넛 젤리 음료수 (FXCUP3_nectar) C++
100 / 100
543 ms 1456 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;
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(J > 300*R) return 0;
	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--;){
		if(v[cur].size() == 1 && v[cur][0].a == 0) break;
		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:34:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=0; j<v[cur].size(); j++){
                ~^~~~~~~~~~~~~~
nectar.cpp:36: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 2 ms 248 KB Output is correct
2 Correct 3 ms 356 KB Output is correct
3 Correct 2 ms 356 KB Output is correct
4 Correct 3 ms 432 KB Output is correct
5 Correct 2 ms 432 KB Output is correct
6 Correct 2 ms 432 KB Output is correct
7 Correct 3 ms 432 KB Output is correct
8 Correct 7 ms 432 KB Output is correct
9 Correct 2 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 3 ms 356 KB Output is correct
3 Correct 2 ms 356 KB Output is correct
4 Correct 3 ms 432 KB Output is correct
5 Correct 2 ms 432 KB Output is correct
6 Correct 2 ms 432 KB Output is correct
7 Correct 3 ms 432 KB Output is correct
8 Correct 7 ms 432 KB Output is correct
9 Correct 2 ms 468 KB Output is correct
10 Correct 13 ms 560 KB Output is correct
11 Correct 17 ms 704 KB Output is correct
12 Correct 62 ms 960 KB Output is correct
13 Correct 131 ms 1256 KB Output is correct
14 Correct 18 ms 1256 KB Output is correct
15 Correct 11 ms 1256 KB Output is correct
16 Correct 21 ms 1256 KB Output is correct
17 Correct 543 ms 1256 KB Output is correct
18 Correct 202 ms 1292 KB Output is correct
19 Correct 71 ms 1456 KB Output is correct
20 Correct 80 ms 1456 KB Output is correct
21 Correct 15 ms 1456 KB Output is correct
22 Correct 44 ms 1456 KB Output is correct
23 Correct 17 ms 1456 KB Output is correct