Submission #483272

# Submission time Handle Problem Language Result Execution time Memory
483272 2021-10-28T12:06:16 Z keertan Global Warming (CEOI18_glo) C++17
0 / 100
148 ms 15912 KB
#include <cstdio>
#include <vector>
#include <algorithm>
#include "bits/stdc++.h"
using namespace std;
typedef pair<long long, long long> pii;
int N;
vector<pii> candies;
vector<long long> wagons;
vector<pair<pii, int> > output;
int main() {
    cin>>N;
    for (int i = 0; i < N; i++) {
        long long p, t;
        cin>>p>>t;
        candies.push_back(pii(p + t, t - p));
    }
    sort(candies.begin(), candies.end());
    for (int i = 0; i < N; i++) {
        long long a = candies[i].first, b = -  candies[i].second;
        int pos = lower_bound(wagons.begin(), wagons.end(), b) - wagons.begin();
        if (pos == (int) wagons.size()) {
            wagons.push_back(b);
        } else {
             wagons[pos] = b;
        }
        
        output.push_back(make_pair(pii((a + b) / 2, (a - b) / 2), pos + 1));
    }
    cout<< wagons.size()<<"\n";
    
    for (int i = 0; i < N; i++) {
        cout<<output[i].first.first<<" "<< output[i].first.second<<" "<< output[i].second<<"\n";
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 148 ms 15912 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 37 ms 4112 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 77 ms 8120 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -