제출 #914951

#제출 시각아이디문제언어결과실행 시간메모리
914951guagua0407Cake 3 (JOI19_cake3)C++17
24 / 100
4011 ms9076 KiB
//#pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int,int> #define f first #define s second #define all(x) x.begin(),x.end() #define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int dx[4]={0,0,1,-1}; int dy[4]={1,-1,0,0}; void setIO(string s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); } const int mxn=2e5+5; const ll inf=1e18; ll v[mxn],c[mxn]; ll pre[mxn]; int main() {_ int n,m; cin>>n>>m; vector<pair<int,int>> vec(n); for(int i=0;i<n;i++){ cin>>vec[i].s>>vec[i].f; } sort(all(vec)); for(int i=1;i<=n;i++){ v[i]=vec[i-1].s; } for(int i=1;i<=n;i++){ c[i]=vec[i-1].f; } ll ans=-inf; for(int i=1;i<=n;i++){ //cout<<v[i]<<' '<<c[i]<<'\n'; multiset<int> S; ll sum=0; for(int j=i;j<=n;j++){ S.insert(v[j]); sum+=v[j]; if((int)S.size()>m){ sum-=*S.begin(); S.erase(S.begin()); } if((int)S.size()==m){ ans=max(ans,sum-2*(c[j]-c[i])); } } } cout<<ans<<'\n'; return 0; } //maybe its multiset not set //yeeorz //laborz

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

cake3.cpp: In function 'void setIO(std::string)':
cake3.cpp:15:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     freopen((s + ".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cake3.cpp:16:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |     freopen((s + ".out").c_str(), "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...