답안 #486057

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
486057 2021-11-10T13:35:00 Z flappybird 라멘 (JOI14_ramen) C++14
100 / 100
1 ms 292 KB
#include "ramen.h"
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

void Ramen(int N) {
	if (N == 1) {
		Answer(0, 0);
		return;
	}
	ll i;
	vector<ll> v1;
	vector<ll> v2;
	if (N % 2) {
		for (i = 0; i < N - 1; i += 2) {
			if (Compare(i, i + 1) == -1) v1.push_back(i), v2.push_back(i + 1);
			else v1.push_back(i + 1), v2.push_back(i);
		}
		ll r1, r2;
		if (Compare(N - 1, N - 2) == -1) {
			if (v1[v1.size() - 1] == N - 2) v1.pop_back();
			v1.push_back(N - 1);
		}
		else {
			if (v2[v2.size() - 1] == N - 2) v2.pop_back();
			v2.push_back(N - 1);
		}
	}
	else {
		for (i = 0; i < N; i += 2) {
			if (Compare(i, i + 1) == -1) v1.push_back(i), v2.push_back(i + 1);
			else v1.push_back(i + 1), v2.push_back(i);
		}
	}
	ll aa, bb;
	aa = v1[0];
	for (i = 1; i < v1.size(); i++) if (Compare(aa, v1[i]) == 1) aa = v1[i];
	bb = v2[0];
	for (i = 1; i < v2.size(); i++) if (Compare(bb, v2[i]) == -1) bb = v2[i];
	Answer(aa, bb);
}

Compilation message

ramen.cpp: In function 'void Ramen(int)':
ramen.cpp:20:6: warning: unused variable 'r1' [-Wunused-variable]
   20 |   ll r1, r2;
      |      ^~
ramen.cpp:20:10: warning: unused variable 'r2' [-Wunused-variable]
   20 |   ll r1, r2;
      |          ^~
ramen.cpp:38:16: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |  for (i = 1; i < v1.size(); i++) if (Compare(aa, v1[i]) == 1) aa = v1[i];
      |              ~~^~~~~~~~~~~
ramen.cpp:40:16: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |  for (i = 1; i < v2.size(); i++) if (Compare(bb, v2[i]) == -1) bb = v2[i];
      |              ~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 292 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct