답안 #71940

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
71940 2018-08-26T01:49:35 Z 블랙야크(#2261, cki86201) 천사의 모래시계 (FXCUP3_hourglass) C++17
58 / 100
4 ms 748 KB
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef long long ll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ldouble;

int N;
int d[5050];

int main() {
	for(int i=1;i<=5050;i++) {
		d[i] = 1e9;
		if(i >= 3) d[i] = min(d[i], d[i-3] + 1);
		if(i >= 5) d[i] = min(d[i], d[i-5] + 1);
	}
	scanf("%d", &N);
	printf("%d\n", d[N] == 1e9 ? -1 : d[N]);
	return 0;
}

Compilation message

hourglass.cpp: In function 'int main()':
hourglass.cpp:41:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &N);
  ~~~~~^~~~~~~~~~
hourglass.cpp:37:8: warning: iteration 5049 invokes undefined behavior [-Waggressive-loop-optimizations]
   d[i] = 1e9;
   ~~~~~^~~~~
hourglass.cpp:36:15: note: within this loop
  for(int i=1;i<=5050;i++) {
              ~^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 600 KB Output is correct
2 Correct 3 ms 548 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 600 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 748 KB Output is correct
2 Correct 3 ms 748 KB Output is correct
3 Correct 2 ms 652 KB Output is correct
4 Correct 2 ms 748 KB Output is correct
5 Correct 2 ms 652 KB Output is correct
6 Correct 3 ms 652 KB Output is correct
7 Correct 2 ms 748 KB Output is correct
8 Correct 2 ms 748 KB Output is correct
9 Correct 2 ms 652 KB Output is correct
10 Correct 2 ms 748 KB Output is correct
11 Incorrect 2 ms 652 KB Output isn't correct
12 Correct 3 ms 652 KB Output is correct
13 Correct 3 ms 748 KB Output is correct
14 Correct 3 ms 748 KB Output is correct
15 Correct 2 ms 652 KB Output is correct
16 Correct 3 ms 748 KB Output is correct
17 Correct 2 ms 652 KB Output is correct
18 Correct 3 ms 652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 748 KB Output is correct
2 Correct 2 ms 748 KB Output is correct
3 Correct 4 ms 748 KB Output is correct
4 Correct 3 ms 748 KB Output is correct
5 Correct 2 ms 748 KB Output is correct
6 Correct 3 ms 748 KB Output is correct
7 Correct 2 ms 748 KB Output is correct
8 Correct 2 ms 748 KB Output is correct
9 Correct 3 ms 748 KB Output is correct
10 Correct 2 ms 748 KB Output is correct
11 Correct 3 ms 748 KB Output is correct
12 Correct 3 ms 748 KB Output is correct