이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define MASK(x) (1LL << (x))
#define BIT(x, i) (((x) >> (i)) & 1)
#define ALL(x) (x).begin(), (x).end()
#define REP(i, n) for (int i = 0, _n = n; i < _n; ++i)
#define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i)
#define FORD(i, a, b) for (int i = (a), _b = (b); i >= _b; --i)
#define FORE(it, s) for (__typeof(s.begin()) it = (s).begin(); it != (s).end(); ++it)
template <class U, class V> bool maximize(U &A, const V &B) { return (A < B) ? (A = B, true) : false; }
template <class U, class V> bool minimize(U &A, const V &B) { return (A > B) ? (A = B, true) : false; }
const int MAXN = 1e5 + 5;
namespace sub1 {
bool check(int N, int M, vector <int> X, vector <int> Y, vector <int> W) {
REP(i, M) if(X[i] % 2 == 1) return false;
return true;
}
long long Main(int N, int M, vector <int> X, vector <int> Y, vector <int> W) {
long long ans = 0;
REP(i, M) ans += W[i];
return ans;
}
}
namespace sub2 {
long long pre[2][MAXN];
bool check(int N, int M, vector <int> X, vector <int> Y, vector <int> W) {
REP(i, M) if(X[i] > 1) return false;
return true;
}
long long Main(int N, int M, vector <int> X, vector <int> Y, vector <int> W) {
long long ans = 0;
REP(i, M) pre[X[i]][Y[i]] += W[i];
FOR(i, 1, N - 1) {
pre[0][i] += pre[0][i - 1];
pre[1][i] += pre[1][i - 1];
}
ans = max(pre[0][N - 1], pre[1][N - 1]);
if(N == 2) return ans;
REP(i, N) {
long long val = pre[1][N - 1] - pre[1][i];
maximize(ans, val + pre[0][i]);
}
return ans;
}
}
long long max_weights(int N, int M, vector <int> X, vector <int> Y, vector <int> W) {
if(sub1::check(N, M, X, Y, W)) return sub1::Main(N, M, X, Y, W);
if(sub2::check(N, M, X, Y, W)) return sub2::Main(N, M, X, Y, W);
}
컴파일 시 표준 에러 (stderr) 메시지
fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:53:1: warning: control reaches end of non-void function [-Wreturn-type]
53 | }
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |