Submission #906244

#TimeUsernameProblemLanguageResultExecution timeMemory
906244MatjazSails (IOI07_sails)C++14
90 / 100
1038 ms3520 KiB
// // IOI2007Sails.cpp // // // Created by Matjaz Leonardis on 04/12/2023. // #include <iostream> #include <vector> #include <algorithm> #include <queue> using namespace std; int INF = 100001; int main(){ int N; cin >> N; vector<int> H(N),K(N); for (int i=0;i<N;i++) cin >> H[i] >> K[i]; vector<pair<int,int> > p(N); for (int i=0;i<N;i++) p[i] = make_pair(H[i],K[i]); sort(p.begin(), p.end()); vector<int> S(100005); int prev = 0; for (int i=0;i<N;i++){ S[0] += p[i].first - prev; int k = p[i].second; int delayed_update = 0; for (int j=0;;j++){ if (k == 0) break; if (S[j] >= k){ S[j] -= k; S[j + 1] += k; k = 0; S[j] += delayed_update; } else { k -= S[j]; int tmp = S[j]; S[j] = delayed_update; delayed_update = tmp; } } prev = p[i].first; /*cout << p[i].first<< " " << p[i].second << endl; for (int j=0;j<5;j++) cout << S[j] << endl; cout << endl;*/ } long long total=0; for (int i=0;i<S.size();i++){ total += (((long long)i * (i - 1)) / 2) * S[i]; } cout << total << endl; return 0; }

Compilation message (stderr)

sails.cpp: In function 'int main()':
sails.cpp:58:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |     for (int i=0;i<S.size();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...
#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...