제출 #1124513

#제출 시각아이디문제언어결과실행 시간메모리
1124513caterpillowLasers (NOI19_lasers)C++17
0 / 100
0 ms324 KiB
#include <bits/stdc++.h> using namespace std; typedef pair<int,int> pii; vector<pii> order; int n,m,l,ans; int main(){ freopen("laser.txt","r",stdin); cin>>l>>n; for (int i=0;i<n;i++){ vector<int> nw;int rtot=0,ltot=0; cin>>m;nw.resize(m); for (int j=0;j<m;j++){ cin>>nw[j];rtot+=nw[j]; } for (int j=0;j<m;j++){ rtot-=nw[j]; if (l-rtot-ltot<2*nw[j]){ order.push_back({l-rtot-nw[j]+1,ltot+nw[j]}); } ltot+=nw[j]; } } sort(order.begin(),order.end()); if (order.size()==0){ cout<<0; return 0; } int prv=order[0].second,sub=order[0].second-order[0].first; for (pii i :order){ if (i.second<=prv){ continue; } if (i.first>prv){ ans+=sub+1; sub = i.second-i.first; prv=i.second; } else{ sub+=i.second-prv; prv=i.second; } } cout<<ans+sub+1; }

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

lasers.cpp: In function 'int main()':
lasers.cpp:7:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |     freopen("laser.txt","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...