답안 #292477

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
292477 2020-09-07T05:35:00 Z shrek12357 Go (COCI18_go) C++14
60 / 100
1 ms 384 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <climits>
#include <cmath>
#include <fstream>
#include <queue>
using namespace std;

struct p {
	int a;
	int b;
	int t;
};

int main() {
	int n, m, z;
	cin >> n >> m >> z;
	vector<p> pokeL, pokeR;
	bool atstart = false;
	pokeR.push_back({ m, 0, 2005 });
	for (int i = 0; i < z; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		if (a <= m) {
			pokeL.push_back({ a, b, c });
		}
		else {
			pokeR.push_back({ a, b, c });
		}
		if (a == m) {
			atstart = true;
		}
	}
	if (!atstart) {
		pokeL.push_back({ m, 0, 2005 });
	}
	reverse(pokeL.begin(), pokeL.end());
	int best = 0;
	for (int i = 0; i < pokeR.size(); i++) {
		for (int j = 0; j < pokeL.size(); j++) {
			int time = 2 * (m - pokeL[j].a);
			int cur = 0;
			for (int k = 0; k <= j; k++) {
				if (m - pokeL[k].a < pokeL[k].t) {
					cur += pokeL[k].b;
				}
			}
			for (int k = 0; k <= i; k++) {
				if (pokeR[k].a - m + time < pokeR[k].t) {
					cur += pokeR[k].b;
				}
			}
			best = max(best, cur);
		}
	}
	for (int i = 0; i < pokeL.size(); i++) {
		for (int j = 0; j < pokeR.size(); j++) {
			int time = 2 * (pokeR[j].a - m);
			int cur = 0;
			for (int k = 0; k <= j; k++) {
				if (pokeR[k].a - m < pokeR[k].t) {
					cur += pokeR[k].b;
				}
			}
			for (int k = 0; k <= i; k++) {
				if (m - pokeL[k].a + time < pokeL[k].t) {
					cur += pokeL[k].b;
				}
			}
		}
	}
	cout << best << endl;
}

Compilation message

go.cpp: In function 'int main()':
go.cpp:43:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<p>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |  for (int i = 0; i < pokeR.size(); i++) {
      |                  ~~^~~~~~~~~~~~~~
go.cpp:44:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<p>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |   for (int j = 0; j < pokeL.size(); j++) {
      |                   ~~^~~~~~~~~~~~~~
go.cpp:60:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<p>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |  for (int i = 0; i < pokeL.size(); i++) {
      |                  ~~^~~~~~~~~~~~~~
go.cpp:61:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<p>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |   for (int j = 0; j < pokeR.size(); j++) {
      |                   ~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Incorrect 1 ms 256 KB Output isn't correct
6 Incorrect 1 ms 256 KB Output isn't correct
7 Incorrect 1 ms 256 KB Output isn't correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Incorrect 1 ms 256 KB Output isn't correct