Submission #108870


Source Code Expand

Copy
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>

using namespace std;

typedef pair<int, int> P;

struct str_pair_less {
  bool operator()(P x, P y) const {
    return x.first < y.first;
  }
};

int main()
{
  int N;
  int a, b;
  vector<P> vec;
  vector<P> ans;

  scanf("%d", &N);

  for(int i = 0; i < N; i++) {
    scanf("%d-%d", &a, &b);
    a -= a%5; b = b-b%5+5;
    //cout << a << " " << b << endl;
    vec.push_back(P(a, b));
  }
  sort(vec.begin(), vec.end(), str_pair_less());

  /*for(int i = 0; i < N; i++) {
    cout << vec[i].first << " " << vec[i].second << endl;
    }*/

  ans.push_back(P(vec[0].first, vec[0].second));
  int j = 0;
  for(int i = 1; i < N; i++) {
    if(vec[i].first > ans[j].second) {
      ans.push_back(P(vec[i].first, vec[i].second));
      j++;
    }
    else {
      ans[j].second = vec[i].second;
    }
  }

  for(int i = 0; i < ans.size(); i++) {
    cout << ans[i].first << "-" << ans[i].second << endl;
  }

  return 0;
}

Submission Info

Submission Time
Task D - 感雨時刻の整理
User gamera416
Language C++ (G++ 4.6.4)
Score 0
Code Size 1044 Byte
Status

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:31:47: error: ‘sort’ was not declared in this scope
./Main.cpp:23:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
./Main.cpp:26:27: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]