1006 Sign In and Sign Out - 最大最小值
思路:
用min_element和max_element就好啦~
程式碼如下:
#include<iostream> #include<cstdio> #include<algorithm> #include<string> #include<cstring> #include<queue> #include<cmath> #include<set> #include<sstream> #define ll long long using namespace std; const int N=1005,INF=0x3f3f3f3f; string id[N],in[N],out[N]; int main(){ int m; scanf("%d",&m); ios::sync_with_stdio(false); for(int i=0;i<m;i++){ cin>>id[i]>>in[i]>>out[i]; } int seq=min_element(in,in+m)-in; cout<<id[seq]<<" "; seq=max_element(out,out+m)-out; cout<<id[seq]<<endl; }
相關推薦
1006 Sign In and Sign Out - 最大最小值
思路: 用min_element和max_element就好啦~ 程式碼如下: #include<iostream> #include<cstdio> #include<algorithm> #include<string> #
1006. Sign In and Sign Out
nta tor details pan ins mit unlock [1] spl 1006. Sign In and Sign Out (25) 時間限制 400 ms 內存限制 65536 kB 代碼長度限制 16000 B 判題程序 Standard
PATA 1006. Sign In and Sign Out (25)
pos esp body () con urn true clas bit #include <bits/stdc++.h> using namespace std; const int N = 100005; struct visitor{ char ID
1006 Sign In and Sign Out (25)
sca div 表示 spec ins input ted nta person At the beginning of every day, the first person who signs in the computer room will unlock the d
1006 Sign In and Sign Out (25 分)
1006 Sign In and Sign Out (25 分) 利用Collections中sort方法 程式碼: import java.util.ArrayList; import java.util.Collections; import java.util.Comparat
1006 Sign In and Sign Out (25 point(s))
1006 Sign In and Sign Out (25 point(s)) At the beginning of every day, the first person who signs in the computer room will unlock the door, and the
PAT甲級 1006 Sign In and Sign Out Java實現
1. 題意 每個人進出這個實驗室,每行給出編號,進入時間,出去的時間 求最早進去的,和最晚出來的 2. 思路 用Java做很方便,可以直接用字串比較compareTo() 來比較時間的早晚 3. 程式碼 package adv1006; import java.io
1006 Sign In and Sign Out
isp style ios -c sed algorithm namespace 分享圖片 code 水題~ #include<iostream> #include<algorithm> #include<string.h> #def
PAT--1006 Sign In and Sign Out (25 分)
1006 Sign In and Sign Out (25 分) At the beginning of every day, the first person who signs in the computer room will unlock the door, and the
PAT 1006 Sign In and Sign Out (25 分)
1006 Sign In and Sign Out (25 分) At the beginning of every day, the first person who signs in the computer room will unlock the do
pat甲級1006 Sign In and Sign Out
#include<iostream> #include<string> #include<stdio.h> using namespace std; int main() { int n; string lock, unlock,id;
PAT (Advanced Level) 1006 Sign In and Sign Out (25 分)
1006 Sign In and Sign Out (25 分) At the beginning of every day, the first person who signs in the computer room will unlock the door, and the
PAT (Advanced Level) Practice 1006 Sign In and Sign Out (25 分)(C++)(甲級)
1006 Sign In and Sign Out (25 分) At the beginning of every day, the first person who signs in the computer room will unlock the door, and the
PAT甲級真題(字串)——1006 Sign In and Sign Out (25 分)
1006 Sign In and Sign Out (25 分) At the beginning of every day, the first person who signs in the computer room will unlock the door, and the
(PAT甲級)1006 Sign In and Sign Out (C語言實現)
code: conclusion: 1、總體思路是:構建結構體陣列,每一個id都和對應的signin、signout聯絡起來,然後對signin進行升序排列,輸出第一個id;接著對signout進行降序排列,輸出第一個id。便得到了開門和鎖門的人對應的ID。 2、開
PAT-ADVANCED1006——Sign In and Sign Out
我的PAT-ADVANCED程式碼倉:https://github.com/617076674/PAT-ADVANCED 原題連結:https://pintia.cn/problem-sets/994805342720868352/problems/994805516654460928
PTA A1006 Sign In and Sign Out
#include<cstdio> struct sign{ char name[16]; char unlock_time[16]; char lock_time[16]; }e
模擬退火演算法求函式最大、小值——python實現
模擬退火演算法(Simulate Anneal,SA)是一種通用概率演演算法,用來在一個大的搜尋空間內找尋命題的最優解。模擬退火是由S.Kirkpatrick, C.D.Gelatt和M.P.Vecchi在1983年所發明的。V.Černý在1985年也獨
[LeetCode] Find Largest Value in Each Tree Row 找樹每行最大的結點值
You need to find the largest value in each row of a binary tree. Example: Input: 1 / \ 3 2 / \ \
Stack with max and min 查詢堆中最大最小數
國外algorithm 課後的一個小quiz: Create a data structure that efficiently supports the stack operations (pus