답안 #483208

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
483208 2021-10-28T07:44:09 Z keertan Global Warming (CEOI18_glo) C++17
0 / 100
93 ms 15936 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() {
    scanf("%d", &N);
    for (int i = 0; i < N; i++) {
        long long p, t;
        scanf("%lld%lld", &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));
    }
    printf("%d\n", wagons.size());
    for (int i = 0; i < N; i++) {
        printf("%lld %lld %d\n", output[i].first.first, output[i].first.second, output[i].second);
    }
    return 0;
}

Compilation message

glo.cpp: In function 'int main()':
glo.cpp:30:14: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wformat=]
   30 |     printf("%d\n", wagons.size());
      |             ~^     ~~~~~~~~~~~~~
      |              |                |
      |              int              std::vector<long long int>::size_type {aka long unsigned int}
      |             %ld
glo.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     scanf("%d", &N);
      |     ~~~~~^~~~~~~~~~
glo.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         scanf("%lld%lld", &p, &t);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 93 ms 15936 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 24 ms 4020 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 48 ms 8072 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -