結果
問題 | No.2154 あさかつの参加人数 |
ユーザー |
|
提出日時 | 2023-03-17 16:12:33 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 271 ms / 2,000 ms |
コード長 | 950 bytes |
コンパイル時間 | 870 ms |
コンパイル使用メモリ | 86,776 KB |
最終ジャッジ日時 | 2025-02-11 12:25:10 |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 25 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:30:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 30 | scanf("%d %d", &n, &m); | ~~~~~^~~~~~~~~~~~~~~~~ main.cpp:33:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 33 | scanf("%d %d", &l, &r); | ~~~~~^~~~~~~~~~~~~~~~~
ソースコード
#include<stdio.h> #include<string.h> #include<stdlib.h> #include <map> #include <vector> #include <queue> #include <deque> #include <set> #include <stack> #include <algorithm> #include <array> #include <unordered_set> #include <unordered_map> #include <string> using namespace std; bool rcmp(int a, int b) { return a>b; } typedef long long LL; typedef struct { int i, x; } RNode; RNode rs[1000004]; bool mycmp(const RNode& a, const RNode& b) { if (a.i!=b.i) return a.i<b.i; return a.x<b.x; } int main() { int n, i, m, k, l, r, j, c; scanf("%d %d", &n, &m); k=0; for (i=0; i<m; i++) { scanf("%d %d", &l, &r); l=n-l+1; r=n-r+1; rs[k].i=l; rs[k].x=1; k++; rs[k].i=r+1; rs[k].x=-1; k++; } sort(rs, rs+k, mycmp); c=0; for (i=0, j=1; j<=n; j++) { while(i<k&&rs[i].i==j) { c+=rs[i].x; i++; } printf("%d\n", c); } return 0; }