제출 #970251

#제출 시각아이디문제언어결과실행 시간메모리
970251NoMercySails (IOI07_sails)C++14
0 / 100
1069 ms8996 KiB
#include <bits/stdc++.h> using namespace std; int TIME = clock(); #define file \ freopen("in.txt" , "r" , stdin); \ freopen("out.txt" , "w" , stdout); typedef long long ll; void test_case () { int n , mx = 0; cin >> n; vector<array<int , 2>> a(n); for (int i = 0;i < n;i ++) { cin >> a[i][0] >> a[i][1]; mx = max(mx , a[i][0]); } set<pair<int , int>> s; for (int i = 0;i < mx;i ++) { s.insert({0 , i}); } ll res = 0; for (int i = n - 1;i >= 0;i --) { vector<pair<int , int>> _s; while (a[i][1] --) { assert((int)s.size() > 0); auto it = *s.begin(); s.erase(s.begin()); if (it.second >= a[i][0]) { a[i][1] ++; _s.push_back(it); continue; } res += it.first; _s.push_back({it.first + 1 , it.second}); } for (int j = 0;j < (int)_s.size();j ++) { s.insert(_s[j]); } } cout << res << "\n"; } int32_t main () { //// file int t = 1; // cin >> t; while (t --) { test_case(); } cerr << "\nTime elapsed: " << (clock() - TIME) * 1000.0 / CLOCKS_PER_SEC << " ms\n"; return 0; }
#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...
#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...