Submission #882897

# Submission time Handle Problem Language Result Execution time Memory
882897 2023-12-04T05:17:41 Z Matjaz Sails (IOI07_sails) C++14
15 / 100
1000 ms 4832 KB
//
//  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<int> S(100001);
    
    for (int i=N-1;i>=0;i--){
        
        priority_queue<pair<int,int> > Q;
        for (int j=1;j<=H[i];j++) Q.push(make_pair(-S[j], j));
        
        for (int j=0;j<K[i];j++){
            S[Q.top().second]++; Q.pop();
        }
    }
    
    long long total=0;
    
    for (int i=0;i<S.size();i++){
        total += ((long long)S[i] * (S[i] - 1)) / 2;
    }
    
    cout << total << endl;
    
    
    return 0;
}


Compilation message

sails.cpp: In function 'int main()':
sails.cpp:38:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     for (int i=0;i<S.size();i++){
      |                  ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 297 ms 916 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1045 ms 1604 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1027 ms 2104 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1051 ms 2748 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1012 ms 4184 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1045 ms 4296 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1099 ms 4832 KB Time limit exceeded
2 Halted 0 ms 0 KB -