Submission #422937

#TimeUsernameProblemLanguageResultExecution timeMemory
422937EndRaySails (IOI07_sails)C++17
10 / 100
1089 ms2848 KiB
#include<bits/stdc++.h> #define ll long long using namespace std; const int N = 1e5+1; int n; pair<int, int> p[N]; int main(){ ios_base::sync_with_stdio(false); cout.tie(0); cin.tie(0); cin >> n; for(int i = 0; i < n; ++i) cin >> p[i].first >> p[i].second; sort(p, p+n); vector<ll> v; for(int i = 0; i < n; ++i){ while(v.size() < p[i].first) v.push_back(0); for(int j = 0; j < p[i].second; ++j) ++v[v.size()-1-j]; sort(v.begin(), v.end(), greater<ll>()); } ll ans = 0; for(int i = 0; i < n; ++i) ans += (v[i]-1)*v[i]/2; cout << ans << "\n"; }

Compilation message (stderr)

sails.cpp: In function 'int main()':
sails.cpp:21:24: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   21 |         while(v.size() < p[i].first)
      |               ~~~~~~~~~^~~~~~~~~~~~
#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...