代码:
# include <iostream>
# include <map>
# include <cstdio>
using namespace std ;
int read ( )
{
int a ;
char c = getchar ( ) ;
while ( c < '0' || c > '9' )
{
c = getchar ( ) ;
}
while ( c >= '0' && c <= '9' )
{
a = a * 10 + c - '0' ;
c = getchar ( ) ;
}
return a ;
}
int pay ( int t )
{
if ( t <= 43200 )
{
t /= 1800 ;
return t * 5 ;
}
else
{
t /= 3600 ;
return t * 15 ;
}
}
map < int , int > time ;
int main ( )
{
ios :: sync_with_stdio ( 0 ) ;
int n = read ( ) ;
for ( int u , t , p ; cin >> u >> t >> p ; )
{
if ( p )
{
cout << "You need to pay " << pay ( t - time [ u ] )
<< " yuan. Good luck.\n" ;
time . erase ( u ) ;
}
else
{
if ( time . size ( ) == n )
{
cout << "Sorry, Jinlanwan is full.\n" ;
}
else
{
cout << "Welcome to Jinlanwan.\n" ;
time [ u ] = t ;
}
}
}
return 0 ;
}
输入:
1
1 1 0
1 2 1
1 3 0
2 4 0
1 1900 1
1 1901 0
1 46000 1
输出
Welcome to Jinlanwan.
You need to pay 0 yuan. Good luck.
Welcome to Jinlanwan.
Sorry, Jinlanwan is full.
You need to pay 5 yuan. Good luck.
Welcome to Jinlanwan.
You need to pay 180 yuan. Good luck.
在本地可以通过,但在洛谷上就什么都不输出。