이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
struct point{int x, y;long long val;};
point tab1[2010], tab2[2010];
long long X1, X2,Y1, Y2;
bool cmp(point a, point b){
if(X1==X2)return a.x<b.x;
return (long long)a.x*((Y1-Y2)/(X1-X2))+a.y < (long long)b.x*((Y1-Y2)/(X1-X2))+b.y;
}
int main(){
int n, i, j;
scanf("%d", &n);
long long res = 0;
for(i=0;i<n;i++){
scanf("%d%d%lld", &tab1[i].x, &tab1[i].y, &tab1[i].val);
tab2[i] = tab1[i];
res = max(res, tab1[i].val);
}
for(i=0;i<n;i++){
for(j=i+1;j<n;j++){
X1 = tab1[i].x;
Y1 = tab1[i].y;
X2 = tab1[j].x;
Y2 = tab1[j].y;
sort(tab2, tab2+n, cmp);
int z=-1;
long long suma=0, suma1=0, suma2=0;
for(int ij=0;ij<n;ij++){
suma+=tab2[ij].val;
if(tab2[ij].x==tab1[i].x && tab2[ij].y==tab1[i].y)
suma1 = suma;
if(tab2[ij].x==tab1[j].x && tab2[ij].y==tab1[j].y){
suma2 = suma;
z = ij;
}
}
suma = 0;
res = max(res, max(suma1,suma2)-suma);
for(int ij=0;ij<n;ij++){
suma+=tab2[ij].val;
if(ij<z)res = max(res, max(suma1,suma2)-suma);
else
res = max(res, suma-min(suma1-tab1[i].val, suma2-tab1[j].val));
}
}
}
printf("%lld\n", res);
}
컴파일 시 표준 에러 (stderr) 메시지
bulldozer.cpp: In function 'int main()':
bulldozer.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
12 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
bulldozer.cpp:15:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
15 | scanf("%d%d%lld", &tab1[i].x, &tab1[i].y, &tab1[i].val);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | 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... |