이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define ll long long
void print(ll Z) {
cout << Z << endl;
}
ll L, R;
vector<ll> V1;
vector<ll> V2;
ll X1, X2;
ll totalX1 = 0;
ll totalX2 = 0;
ll maxZA = -1;
ll maxZ = 0;
ll maxA = 0;
bool flag[1000008];
ll work3() {
if(totalX1 <= L/2 and totalX2 <= L/2) {
return 0;
}
else if(X1 == 1 and X2 == 1) {
return ((maxZA -(L / 2))*2 - 1);
}
else if(totalX1 > L/2 and totalX2 <= L/2) {
if(maxZ <= L/2) {
return 0;
}
else {
return totalX1 - L/2;
}
}
else if(totalX2 > L/2 and totalX1 <= L/2) {
if(maxA <= L/2) {
return 0;
}
else {
return totalX2 - L/2;
}
}
else {
if(maxZ <= L/2 and maxA <= L/2) {
return 0;
}
else {
return max(totalX2 - L/2, totalX1 - L/2);
}
}
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> L >> R;
if(R == 1) {
// Subtask 1
ll X;
cin >> X;
if(X == 1) {
ll Y;
cin >> Y;
if(Y > L/2) {
if(L % 2) print((Y -(L / 2))*2 - 1);
else print((Y - (L / 2))*2);
}
else print(0);
}
}
else if(R == 2) {
// Subtask 3
cin >> X1;
for(int i=0; i<X1; i++) {
ll Z;
cin >> Z;
V1.push_back(Z);
totalX1 += Z;
maxZA = max(maxZA, Z);
}
maxZ = maxZA;
cin >> X2;
for(int i=0; i<X2; i++) {
ll A;
cin >> A;
V2.push_back(A);
totalX2 += A;
maxZA = max(maxZA, A);
maxA = max(A, maxA);
}
ll ans = work3();
print(ans);
}
else {
ll ans = 0;
ll maxY = 0;
while(R--){
ll X;
cin >> X;
if(X == 1) {
// Subtask 2
ll Y;
cin >> Y;
maxY = max(maxY, Y);
}
}
if(maxY > L/2) {
if(L % 2) print((maxY -(L / 2))*2 - 1);
else print((maxY - (L / 2))*2);
}
else print(0);
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
lasers.cpp: In function 'int main()':
lasers.cpp:92:12: warning: unused variable 'ans' [-Wunused-variable]
92 | ll ans = 0;
| ^~~
# | 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... |