QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#882501#9879. ReTravellsxhyydsWA 1ms3712kbC++144.1kb2025-02-05 08:36:522025-02-05 08:36:53

Judging History

This is the latest submission verdict.

  • [2025-02-05 08:36:53]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3712kb
  • [2025-02-05 08:36:52]
  • Submitted

answer

//#ifndef fio
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse3","sse2","sse")
//#pragma GCC target("avx","sse4","sse4.1","sse4.2","ssse3")
//#pragma GCC target("f16c")
//#pragma GCC optimize("inline","fast-math","unroll-loops","no-stack-protector")
//#pragma GCC diagnostic error "-fwhole-program"
//#pragma GCC diagnostic error "-fcse-skip-blocks"
//#pragma GCC diagnostic error "-funsafe-loop-optimizations"
//#pragma GCC diagnostic error "-std=c++20"
//#endif
#include <bits/stdc++.h>
#define N 1000005
#define M 3000005
#define ll long long
#define uint unsigned int
#define ull unsigned long long
#define i128 __int128
#define mk make_pair
#define x first
#define y second
//#define bas 20200721
//#define bas 1000000007
#define ls(x) (x<<1)
#define rs(x) (x<<1|1)
#define VI vector<int>
#define VL vector<ll>
#define lowbit(x) (x&(-x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PIL pair<int,ll>
#define PLI pair<ll,int>
#define PDI pair<double,int>
#define PDD pair<double,double>
#define PVL pair<VI,ll>
#define eps (1e-9)
#define mod 1000000007
//#define double long double
#define int long long
using namespace std;
//int mod=998244353;
const double Pi=acos(-1);
struct mint {
	int x;
	mint() : x(0) {}
	mint(long long y, bool flag = 0) {
		if (flag) x = (int)(y);
		else x = (int)((y % mod + mod) % mod);
	}
	friend const mint ksm(mint a, long long b);
	const mint inv() {return ksm(*this, mod - 2);}
};
bool operator == (const mint a, const mint b) {return a.x == b.x;}
bool operator != (const mint a, const mint b) {return a.x != b.x;}
bool operator <(const mint a,const mint b){return a.x<b.x;}
bool operator >(const mint a,const mint b){return a.x>b.x;}
int operator ! (const mint a) {return !a.x;}
const mint operator + (const mint a, const mint b) {
	mint res(a.x + b.x, 1);
	if (res.x >= mod) res.x -= mod;
	return res;
}
mint& operator += (mint &a, const mint b) {
	a.x += b.x;
	if (a.x >= mod) a.x -= mod;
	return a;
}
const mint operator - (const mint a, const mint b) {
	mint res(a.x - b.x, 1);
	if (res.x < 0) res.x += mod;
	return res;
}
mint& operator -= (mint &a, const mint b) {
	a.x -= b.x;
	if (a.x < 0) a.x += mod;
	return a;
}
const mint operator * (const mint a, const mint b) {
	return mint((long long)a.x * b.x % mod, 1);
}
mint& operator *= (mint &a, const mint b) {
	a.x = (int)((long long)a.x * b.x % mod);
	return a;
}
const mint ksm(mint a, long long b) {
	mint res(1, 1);
	for (; b; a *= a, b >>= 1)
		if (b & 1) res *= a;
	return res;
}
const mint operator / (const mint a, const mint b) {
	return a * ksm(b, mod - 2);
}
mint& operator /= (mint &a, const mint b) {
	a = a * ksm(b, mod - 2);
	return a;
}
ostream& operator << (ostream &out, const mint a) {
	return out << a.x;
}
istream& operator >> (istream &in, mint &a) {
	long long y;
	in >> y, a = mint(y);
	return in;
}
PLL operator +(PLL a,PLL b){
	return mk(a.x+b.x,a.y+b.y);
}
PLL operator +=(PLL &a,const PLL b){
	a=a+b;
	return a;
}
PLL operator *(PLL a,int b){
	a=mk(a.x*b,a.y*b);
	return a;
}
void chkmx(ll &x,ll y){
	x=max(x,y);
}
void chkmn(ll &x,ll y){
	x=min(x,y);
}

int tt;
int n,m,q,k;
string s;
// int a[N];/
PII a[N];
void solve(){	
	cin>>n;
	for(int i=1;i<=n;++i){
		// int x,y;
		cin>>a[i].x>>a[i].y;
	}
	ll ans=a[1].x+a[1].y;
	vector<PII> jj;
	jj.push_back(mk(0,0));
	jj.push_back(mk(a[1].x,a[1].y));
	for(int i=2;i<=n;++i){
		if(jj.back().x<=a[i].x&&jj.back().y<=a[i].y){
			ans+=1ll*a[i].x-jj.back().x+a[i].y-jj.back().y;
			jj.push_back(a[i]);
			continue;
		}
		while(1){
			int x=jj.back().x,y=jj.back().y;
			jj.pop_back();
			int qx=jj.back().x,qy=jj.back().y;
			if(qx<=a[i].x&&qy<=a[i].y){
				int cx,cy;
				cx=min(x,a[i].x);
				cy=min(y,a[i].y);
				jj.push_back(mk(cx,cy));
				ans+=1ll*a[i].x-cx+a[i].y-cy;
				jj.push_back(a[i]);
				break;
			}
		}
	}
	cout<<ans<<'\n';
}
signed main(){
	// freopen("line.in","r",stdin);
	// freopen("line.out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	// cin>>tt;
	// while(tt--){
		solve();
		
	// }	
	return 0;
}
/*

*/

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3712kb

input:

2
3 3
1 2

output:

6

result:

ok "6"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3584kb

input:

3
2 2
3 3
1 3

output:

7

result:

ok "7"

Test #3:

score: -100
Wrong Answer
time: 1ms
memory: 3712kb

input:

500
906691059 413653999
813847339 955892128
451585301 43469773
278009742 548977048
521760889 434794718
985946604 841597326
891047768 325679554
511742081 384452587
626401695 957413342
975078788 234551094
541903389 149544006
302621084 150050891
811538590 101823753
663968655 858351976
268979133 9768326...

output:

233625568926

result:

wrong answer 1st words differ - expected: '202616034783', found: '233625568926'