Submission #1110198

#TimeUsernameProblemLanguageResultExecution timeMemory
1110198vjudge1Ski 2 (JOI24_ski2)C++17
0 / 100
1 ms512 KiB
#include<bits/stdc++.h> using namespace std; int n,k; pair<int,int>a[500]; vector<int>g; int lma=0; int mn; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if(fopen("c.INP","r")){ freopen("c.INP","r",stdin); freopen("c.OUT","w",stdout); } cin >>n>>k; int asw=0; for(int i=1;i<=n;i++){ cin >>a[i].first>>a[i].second; } sort(a+1,a+n+1); int mn=a[1].second; int i=2; lma=1; for(;i<=n;i++){ if(a[i].first==a[1].first){ a[i].first++; asw+=k; if(!lma)asw+=a[1].second; else lma--; g.push_back(a[i].second); } else break; } for(;i<=n;i++){ if(a[i].first!=a[i-1].first){ for(auto o:g){ mn=min(mn,o); lma++; } g.clear(); } if(!lma)asw+=mn; else lma--; g.push_back(a[i].second); } cout <<asw; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:13:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |         freopen("c.INP","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~
Main.cpp:14:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |         freopen("c.OUT","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~
#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...