제출 #23563

#제출 시각아이디문제언어결과실행 시간메모리
23563TAMREFFireworks (APIO16_fireworks)C++11
7 / 100
3 ms9052 KiB
#include <bits/stdc++.h> #define va first #define vb second using namespace std; typedef long long ll; typedef pair<int,int> pii; const ll INF=1<<45; const int MX=300005; int N,M; vector<pii> G[300005]; void input(){ scanf("%d%d",&N,&M); for(int i=2,x,y;i<=N+M;i++){ scanf("%d%d",&x,&y); G[i].push_back(make_pair(x,y)); G[x].push_back(make_pair(i,y)); } } void case1(){ int p=0,q,r,s=INT_MAX; auto pro = [=](int x)->ll{ ll S=0; for(pii u : G[1]){ S+=llabs((ll)u.vb-x); //cout<<u.va<<' '<<u.vb<<" : "<<S<<endl; } return S; }; while(p<s){ q=p+(s-p)/3,r=s-(s-p)/3; if(pro(q)<=pro(r)) s=r-1; else p=q+1; } printf("%lld\n",pro(p)); exit(0); } int main(){ input(); if(N==1) case1(); else return 0; }

컴파일 시 표준 에러 (stderr) 메시지

fireworks.cpp:7:17: warning: left shift count >= width of type [-Wshift-count-overflow]
 const ll INF=1<<45;
                 ^
fireworks.cpp: In function 'void input()':
fireworks.cpp:12:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&N,&M);
                        ^
fireworks.cpp:14:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d",&x,&y);
                            ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...