Submission #1036327

#TimeUsernameProblemLanguageResultExecution timeMemory
1036327UnforgettableplSki 2 (JOI24_ski2)C++17
5 / 100
1 ms504 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int32_t main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int n,k; cin >> n >> k; vector<vector<int>> arr(301); vector<pair<int,int>> temp; int offset = 300; for(int i=1;i<=n;i++){ int h,c; cin >> h >> c; offset=min(offset,h); temp.emplace_back(h,c); } for(auto&[h,c]:temp)arr[h-offset].emplace_back(c); for(int&i:arr[0])if(i<arr[0][0])swap(i,arr[0][0]); int ans = 0; for(int i=1;i<arr[0].size();i++){ ans+=k; arr[1].emplace_back(arr[0][i]); } arr[0].resize(1); int free = 1; int currmin = arr[0][0]; for(int i=1;i<=300;i++){ for(int&x:arr[i]){ if(free)free--; else ans+=currmin; } for(int&x:arr[i]){ free++; currmin=min(currmin,x); } } cout << ans << '\n'; }

Compilation message (stderr)

Main.cpp: In function 'int32_t main()':
Main.cpp:23:15: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |  for(int i=1;i<arr[0].size();i++){
      |              ~^~~~~~~~~~~~~~
Main.cpp:31:11: warning: unused variable 'x' [-Wunused-variable]
   31 |   for(int&x:arr[i]){
      |           ^
#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...