# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
292487 | shrek12357 | Go (COCI18_go) | C++14 | 1 ms | 256 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
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 if(a > m) {
pokeR.push_back({ a, b, c });
}
else {
pokeR.push_back({ a, b, c });
pokeL.push_back({ a, b, c });
}
}
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++) {
bool ok = false;
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;
if (k == i) {
ok = true;
}
}
}
if (ok) {
best = max(best, cur);
}
}
}
for (int i = 0; i < pokeL.size(); i++) {
for (int j = 0; j < pokeR.size(); j++) {
bool ok = false;
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;
if (k == i) {
ok = true;
}
}
}
if (ok) {
best = max(best, cur);
}
}
}
cout << best << endl;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |